|
login.asp
<!--#include file="conn.asp"-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title></title>
<link href="css.css" rel="stylesheet" type="text/css" />
<SCRIPT language=javascript>
<!--
function chkuser()
{
if (login.username.value=="")
{
alert("请输入用户名!");
login.username.focus();
return false;
}
if (login.password.value=="")
{
alert("请输入密码!");
login.password.focus();
return false;
}
if (login.passcode.value=="")
{
alert("请输入验证码!");
login.passcode.focus();
return false;
}
}
//-->
</SCRIPT>
</head>
<body>
<table width="100%">
<tr>
<td><%
dim username
username=request.Cookies("shoptimes")("username")
IF username="" then
%>
<table width="100%">
<tr>
<td height="30" colspan="3" class="tableborder" > 会员登录 </td>
</tr>
<form action="chklogin.asp" method="post" name="login" id="login" onsubmit="return chkuser();" >
<tr>
<td width="280" height="25" align="left">用户名:</td>
<td width="448" height="25"><input name="username" type="text" id="username" size="15" maxlength="12" />
</td>
<td width="23" height="30"> </td>
</tr>
<tr>
<td height="25" align="left">密 码:</td>
<td height="25"><input name="password" type="password" id="password" size="15" maxlength="18" />
</td>
<td height="30"> </td>
</tr>
<tr>
<td height="25" align="left">验证码:</td>
<td height="25"><input name="passcode" type="text" id="passcode" size="8" maxlength="4" />
<img src="Code.asp"> </td>
<td height="30"> </td>
</tr>
<tr>
<td height="25"></td>
<td height="25"><a href="reg.asp">新用户注册</a>
<input type="submit" name="Submit" value="登录" /></td>
<td height="30"> </td>
</tr>
</form>
</table>
<% else
Dim rs,Sql
set rs=Server.CreateObject("Adodb.Recordset")
Sql="select * from userinfo where username='"&username&"'"
rs.open Sql,conn,1,1
%>
<table width="100%">
<tr>
<td align="center"><marquee scrollamount="1" scrolldelay="1" direction="down" height="100">
<div align="center"> <%= username %>您是<br />
<span style="color:#FF0000">
<% select case rs("rank")
case "0"
Response.Write("普通会号")
case "1"
Response.Write("市级代理")
case "2"
Response.Write("省级代理")
end select
%>
</span><br />
<%= rs("message") %> </div>
</marquee>
</td>
</tr>
</table>
<% end if %></td>
</tr>
</table>
</body>
</html>
chklogin.asp
<!--#include file="conn.asp"-->
<!--#include file="md5.asp"-->
<%
dim username,password,code,sql
username=Trim(Request.Form("username"))
password=md5(Trim(Request.Form("password")))
passcode=Request.Form("passcode")
if not isnumeric(passcode) then
response.Write"<script language='javascript'>alert('验证码为数字!');history.go(-1)</script>"
response.End()
end if
set rs=server.CreateObject("adodb.recordset")
sql="select * from userinfo where username='"&username&"'"
rs.open sql,conn,1,3
if rs.bof and rs.eof then
response.Write"<script language='javascript'>alert('请检查用户名!');history.go(-1)</script>"
response.end
else
if password<>rs("password") then
Response.Write"<script language='javascript'>alert('密码错误!');history.go(-1)</script>"
response.End
end if
if int(passcode)<>Session("GetCode") then
Response.Write"<script language='javascript'>alert('验证码错误!');history.go(-1)</script>"
response.End
end if
response.Cookies("shoptimes")("username")=name
response.cookies("shoptimes")("rank")=rs("rank")
rs("lastlogin")=now()
rs("logintimes")=rs("logintimes")+1
rs("cent")=rs("cent")+2
rs.Update
rs.Close
set rs=nothing
end if
response.Redirect "msg.asp?msg=rightmsg"
%> |
|