账号登陆密码验证问题
asp缓存中的一个问题,我在会员登陆的时候需要增加一个检查该帐号是否激活的功能,不知道怎么加,整个程序用的缓存,数据库中我在表user里增加列“jihuo”,0表示未激活,1表示激活,目的是让用户登录的时候根据列“jihuo”的值来判断是否激活。下面是缓存文件中的相关登陆的代码,请各位帮忙,先谢谢了!
'检查是否登陆,如果没登就转到登陆页
Public Function CheckLogin(GoLogin,InFrame)
if Trim(Session(SN & "UserName"))<>"" then
UserID=Session(SN & "UserID")
UserName=Session(SN & "UserName")
elseif Request.Cookies(SN)(SN&"UserName")<>"" and Request.Cookies(SN)(SN&"UserPwd")<>"" then
dim name,pwd,rs
name=Request.Cookies(SN)(SN&"UserName")
pwd=Request.Cookies(SN)(SN&"UserPwd")
Set rs=Execute("select * from User where name='" &name& "' and pwd='" &pwd& "'")
if not rs.eof then
session(SN & "UserID")= rs("ID")
Session(SN & "UserName") = name
UserID=Session(SN & "UserID")
UserName=Session(SN & "UserName")
Response.Cookies(SN).Expires=Date+1
Response.Cookies(SN)(SN&"UserName") = name
Response.Cookies(SN)(SN&"UserPwd") = pwd
Response.Cookies(SN)(SN&"Md5Name") = md5(name)
else
Session(SN & "UserID") = 0
Session(SN & "UserName") = ""
UserID=0
UserName=""
Response.Cookies(SN) = Empty
end if
rs.Close
Set rs=Nothing
else
UserID=0
UserName=""
end if
if UserName<>"" then
CheckLogin=True
else
CheckLogin=False
if GoLogin=True then
if InFrame=True then
dim url
url=Request.ServerVariables("PATH_INFO") & "?" & Request.ServerVariables("QUERY_STRING")
if right(url,1)="#" then url=left(url,len(url)-1)
Response.redirect(weburl & "login.asp?inframe=1&url=" & Server.URLEncode(url))
else
Response.redirect(weburl & "login.asp")
end if
end if
end if
End Function
'登陆
Public Function TrueLogin(Name,Pwd)
if UserName=Name and Request.Cookies(SN)(SN&"UserName")<>"" and Request.Cookies(SN)(SN&"UserPwd")<>"" then
TrueLogin=True
Response.Cookies(SN).Expires=Date+1
Exit Function
end if
Dim rs
TrueLogin=False
Set rs=Execute("select * from User where name='"&name&"' and pwd='"&pwd&"'")
if rs.Eof then
rs.close
response.write "<script>alert('用户名或密码错误!'); history.back();</script>"
response.end
else
session(SN & "UserID")= rs("ID")
Session(SN & "UserName") = name
UserID=Session(SN & "UserID")
UserName=Session(SN & "UserName")
Response.Cookies(SN).Expires=Date+1
Response.Cookies(SN)(SN&"UserName") = name
Response.Cookies(SN)(SN&"UserPwd") = md5(pwd)
Response.Cookies(SN)(SN&"Md5Name") = md5(name)
rs.Close
Execute("update User set LoginCount=LoginCount+1, logintime=" & SqlNowString & " where name='"&name&"'")
TrueLogin=True
end if
Set rs=nothing
End Function