📄 user_chklogin.asp
字号:
<%@language=vbscript codepage=936 %>
<!--#include file="inc/Conn_User.asp"-->
<!--#include file="inc/md5.asp"-->
<%
dim sql,rs
dim username,password,CookieDate
username=replace(trim(request("username")),"'","")
password=replace(trim(Request("password")),"'","")
CookieDate=trim(request("CookieDate"))
dim ComeUrl
ComeUrl=trim(request("ComeUrl"))
if ComeUrl="" then
ComeUrl=Request.ServerVariables("HTTP_REFERER")
if ComeUrl="" then ComeUrl="index.asp" end if
end if
if UserName="" then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>用户名不能为空!</li>"
end if
if Password="" then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>密码不能为空!</li>"
end if
if CookieDate="" then
CookieDate=0
else
CookieDate=Clng(CookieDate)
end if
if FoundErr<>True then
password=md5(password)
set rs=server.createobject("adodb.recordset")
sql="select * from " & db_User_Table & " where " & db_User_Name & "='" & username & "' and " & db_User_Password & "='" & password &"'"
rs.open sql,Conn_User,1,3
if rs.bof and rs.eof then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>用户名或密码错误!!!</li>"
else
if password<>rs(db_User_Password) then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>用户名或密码错误!!!</li>"
else
if rs(db_User_UserLevel)>999 then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>对不起,你尚未通过认证,不能登录!</li>"
else
rs(db_User_LastLoginIP)=Request.ServerVariables("REMOTE_ADDR")
rs(db_User_LastLoginTime)=now()
rs(db_User_LoginTimes)=rs(db_User_LoginTimes)+1
rs.update
call SaveCookie_asp163()
rs.close
set rs=nothing
call CloseConn_User()
response.redirect ComeUrl
end if
end if
end if
rs.close
set rs=nothing
end if
if FoundErr=True then
call WriteErrMsg()
end if
call CloseConn_User()
sub SaveCookie_asp163()
Response.Cookies("luyeweb")("UserName")=username
Response.Cookies("luyeweb")("Password") = PassWord
Response.Cookies("luyeweb")("UserLevel")=rs("UserLevel")
Response.Cookies("luyeweb")("CookieDate") = CookieDate
select case CookieDate
case 0
'not save
case 1
Response.Cookies("luyeweb").Expires=Date+1
case 2
Response.Cookies("luyeweb").Expires=Date+31
case 3
Response.Cookies("luyeweb").Expires=Date+365
end select
end sub
'****************************************************
'过程名:WriteErrMsg
'作 用:显示错误提示信息
'参 数:无
'****************************************************
sub WriteErrMsg()
dim strErr
strErr=strErr & "<html><head><title>错误信息</title><meta http-equiv='Content-Type' content='text/html; charset=gb2312'>" & vbcrlf
strErr=strErr & "<link href='ad_style.css' rel='stylesheet' type='text/css'></head><body>" & vbcrlf
strErr=strErr & "<table cellpadding=2 cellspacing=1 border=0 width=400 class='border' align=center>" & vbcrlf
strErr=strErr & " <tr align='center'><td height='22' class='title'><strong>错误信息</strong></td></tr>" & vbcrlf
strErr=strErr & " <tr><td height='100' class='tdbg' valign='top'><b>产生错误的可能原因:</b><br>" & errmsg &"</td></tr>" & vbcrlf
strErr=strErr & " <tr align='center'><td class='tdbg'><a href=""User_Login.asp?ComeUrl=" & ComeUrl & """><< 返回登录页面</a></td></tr>" & vbcrlf
strErr=strErr & "</table>" & vbcrlf
strErr=strErr & "</body></html>" & vbcrlf
response.write strErr
end sub
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -