global.asp
script language=vbscript runat=server>
sub Session_onstart
session("register")="false"
' 记录用户成功登录的信息.
session("lognumber")=0
' 记录用户尝试登录的次数,最多允许尝试三次.
session("prescript")=""
' 记录用户要访问的页面,以便登录后返回该页.
end sub
/script>
register.asp
% if request.form("b1")="提交" then
set
conn=server.createobject("adodb.connection")
conn.open "asptest"
sql1="select * from permission where xm='"request.form("name") "' and mima='"request.form ("password")"'"
set rs=conn.execute(sql1)
if not rs.eof then
session("register")="true"
' 若数据库中存在该用户的信息,就记录该用户成功登录的标记到register变量中.
rs.close
conn.close
response.redirect session("prescript")
' 成功登录后自动返回刚才要访问的页面.
end if
if session("lognumber")3 then
session("lognumber")=
session("lognumber")+1
response.redirect "register.asp"
else
response.redirect "sorry.asp"
end if
' 允许尝试登录三次,若都未成功,则显示出错页面sorry.asp.
end if%>
html>head>/head>
body bgcolor="#c0c0c0" >
p align="center">
marquee align="middle"
behavior="alternate" >星河影动欢迎您,请先登录!/marquee>br>
%if session("lognumber")>0 then%>
输入有误!请重新输入姓名和口令.
% end if%>
/p>hr>
form action="register.asp" method="post" name="form1">
div align="center">p>姓名:
input name="name" size="13">/p>
p>口令:input name="password"
size="13"type="password">/p>/div>
div align="right">input type="submit" name="b1" value="提交" >
/div>/form>/body>/html>
protect.asp
' 精彩的要限制的页面.
% if session("register") >"true" then
session("prescript")=
request.servervariables("script_name")
response.redirect "register.asp"
end if%>
' 记录该页面的路径到prescript变量中并强制用户登录.
html>head>
meta http-equiv="Content-Type"
content="text/html; charset=gb_2312-80">/head>
body bgcolor="#00FFFF">
' 此处可注明该页面的精彩内容.
/body>/html>
[1]