<%
dim username
username=trim(request("username"))
if username=""then
response.Write "<center><a href=default.asp><font color=red size=2>对不起,登陆失败,请检查您的登陆名和密码</font></a></center>"
response.end
end if
'用cookies记录登陆状态,通过判断cookies的值来确定是否该用户在线
if request.Cookies("username")=username then
response.Write "<center><a href=default.asp><font color=red size=2>对不起,登陆失败,该用户现处于登陆状态</font></a></center>"
response.end
end if
set rs=server.CreateObject("adodb.recordset")
rs.Open "select * from [user] where username='"&username&"' and userpassword='"&userpassword&"' " ,conn,1,3
if not(rs.bof and rs.eof) then
if userpassword=rs("userpassword") then
Response.Cookies("username")=trim(request("username"))
response.Cookies("username").expires=date+1
rs.Close
set rs=nothing
end if
%>