global.asp
script language=vbscript runat=server>
sub Session_onstart
session("register")="false"
' 記錄用戶成功登錄的信息.
session("lognumber")=0
' 記錄用戶嘗試登錄的次數(shù),最多允許嘗試三次.
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"
' 若數(shù)據(jù)庫中存在該用戶的信息,就記錄該用戶成功登錄的標(biāo)記到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
' 允許嘗試登錄三次,若都未成功,則顯示出錯(cuò)頁面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變量中并強(qiáng)制用戶登錄.
html>head>
meta http-equiv="Content-Type"
content="text/html; charset=gb_2312-80">/head>
body bgcolor="#00FFFF">
' 此處可注明該頁面的精彩內(nèi)容.
/body>/html>
[1]