<!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>asp教程用户登录,退出登录函数</title>
</head><body>
<form action="login.asp" method="post" name="loginform" id="loginform" onsubmit="return check();">
<table width="500" border="0" cellspacing="5" cellpadding="0">
<tr>
<td><strong>用户名:</strong> <input type="text" size="20" name="username">
<strong>密 码:</strong> <input name="userpass" type="password" id="userpass" size="20"></td>
</tr>
<tr>
<td>保持登录:
<input name="issave" type="radio" value="0">
不保存
<input name="issave" type="radio" value="1" checked>
保持一天
<input type="radio" name="issave" value="30">
保持一个月
<input type="submit" name="submit" value="登录"></td>
</tr>
</form>
</body>
</html>
login.asp
<%
on error resume next
set conn=server.createobject("adodb.connection")
conn.open connstr
if err then
response.write ""&issqlver&"数据库教程连接出错,请检查连接字串。<br><br>"&err.source&" ("&err.number&")"
set conn = nothing
err.clear
response.end
end ifdim expires,userpass
username=request("username")
userpass=md5(request("userpass"),16)
expires=request("issave")
if username<>"test" thenset rs=server.createobject("adodb.recordset")
rs.open"select * from lg50_my_user where username='"&username&"' and password='"&userpass&"'",conn,1,3
if rs.eof and rs.bof then
rs.close
set rs=nothing
response.write("<script language=网页特效>alert('请输入正确用户名和密码');this.location.href='login.htm';</script>")
response.end
else
response.cookies(cookiesname)("username")=username
if int(expires)>0 then response.cookies(cookiesname).expires = date+expires
response.redirect ("index.asp")
end ifelse
response.cookies(cookiesname)("username")=username
response.redirect ("index.asp")
response.end
end if
%>
退出登录
<%
if request("out")="bbs" then
response.cookies(cookiesname)("username")=""
response.redirect "/www.111cn.net/login.asp?menu=out&bbs=bbs"
else
response.cookies(cookiesname)("username")=""
response.redirect ("login.htm")
end if
%>