************************* 获取From的值
<%if Request.ServerVariables("Request_Method")="POST" then
set Rs=server.createobject("adodb.recordset")
Username=trim(request.form("name"))
psw=trim(request.form("password"))
************************* 判断不能为空
if Username="" or psw="" then
Response.write "<script>alert('用户名和登陆密码不能为空');</script>"
Response.write "<script>history.go(-1);</script>"
Response.end
end if
************************* 用Session来限制错误输入次数(3次)
if Session("err")>=3 then
errorr=1
errmsg="你已经重试这么多次了,累了吧,请歇会再来,或者联系管理员!"
else
sql="select * from WebMaster where UserName='"&UserName&"'"
Rs.open sql,cn,3,1
if Rs.eof and Rs.bof then
errorr=1
Session("err")=Session("err")+1
errmsg="用户名不存在,请返回重新填写确认!"
Rs.close
elseif psw<>Rs("PassWord") then
errorr=1
Session("err")=Session("err")+1
errmsg="用户名和密码不符,请确认后再输一次!"
Rs.close
end if
end if
if errorr=1 then
Response.write "<script>alert('"&errmsg&"');</script>"
Response.write "<script>history.go(-1);</script>"
Rs.close
Set Rs=Nothing
Cn.Close
Response.end
end if
************************* 检验成功赋值给Session,最后重定向页面。
Response.cookies("UserName")=Rs("UserName")
Response.cookies("UserKey")=Rs("UserKey")
Rs.close
Set Rs=Nothing
Cn.Close
Session("err")=0
Response.write "<script>location.href='MasterMain.asp';</script>"
end if
%>