📄 user_login.asp
字号:
<%@ Language=VBScript%>
<%
Response.Buffer=true
Response.Expires=0
%>
<!-- #include file="../dsn.asp" -->
<!-- #include file="init.inc" -->
<%
myurl="user_login.asp"
tablename="userinfo"
mymenu="usercenter"
set cn = Server.CreateObject("ADODB.Connection")
cn.Open(mycnstr)
set rs = Server.CreateObject("ADODB.Recordset")
set rs2 = Server.CreateObject("ADODB.Recordset")
bz=1
if Request.ServerVariables("REQUEST_METHOD")="POST" then
usercode=trim(Request.Form("usercode"))
userpass=Lcase(trim(Request.Form("userpass")))
cookieqx=Lcase(trim(Request.Form("cookieqx")))
loginflag=Lcase(trim(Request.Form("loginflag")))
sql="select userno,userpass,flag,state,logintime,logincount,ipaddress from userinfo where usercode='"+usercode+"' and state='1'"
rs.Open sql,cn,1,3
if rs.EOF then
bz=2
else
oldpass=Lcase(trim(rs(1)))
if oldpass=userpass then
bz=0
rs("logintime")=now()
rs("logincount")=rs("logincount")+1
rs("ipaddress")=Request.ServerVariables("Remote_HOST")
rs.Update
Response.Cookies("usercode")=usercode
Response.Cookies("userpass")=userpass
Response.Cookies("loginflag")=loginflag
select case cookieqx
case "1"
Response.Cookies("usercode").Expires=now()+1
Response.Cookies("userpass").Expires=now()+1
Response.Cookies("loginflag").Expires=now()+1
case "2"
Response.Cookies("usercode").Expires=now()+30
Response.Cookies("userpass").Expires=now()+30
Response.Cookies("loginflag").Expires=now()+30
case "3"
Response.Cookies("usercode").Expires=now()+365
Response.Cookies("userpass").Expires=now()+365
Response.Cookies("loginflag").Expires=now()+365
end select
Session("userno")=rs(0)
Session("usercode")=usercode
Session("userflag")=rs("flag")
userno=rs(0)
cn.Execute "delete from user_login where userno="&userno&" or keyno="&Session.SessionID
if databaseflag="access" then
sql="Insert into user_login values ("&Session.SessionID&","&userno&",'"+usercode+"',now(),now(),'','"+loginflag+"','"+Request.ServerVariables("Remote_HOST")+"')"
else
sql="Insert into user_login values ("&Session.SessionID&","&userno&",'"+usercode+"',getdate(),getdate(),'','"+loginflag+"','"+Request.ServerVariables("Remote_HOST")+"')"
end if
cn.Execute sql
Response.Redirect("forum.asp")
else
bz=2
Session.Abandon
end if
end if
rs.Close
end if
%>
<!-- #include file="begin.asp" -->
<%if bz=1 or bz=2 then%>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#ffffff">
<tr>
<td height="8"></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center" bgcolor="#FFFFFF">
<tr><td>
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center" height="30" bgcolor=ffffff>
<tr>
<td width="20"> </td>
<td>欢迎光临<%=forumtitle%></td>
<td width="10"> </td>
</tr>
</table>
</td></tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td background="images/shadow1.jpg" height="8"></td>
</tr>
<tr>
<td bgcolor="#CDDCF2" height="1"></td>
</tr>
</table>
<table width="98%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td align="center">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center" height="30" bgcolor="<%=barcolor%>">
<tr>
<td width="10"> </td>
<td width=30 align=center><img src="images/homeflag.gif"></td>
<%if classflag="1" then%>
<td><a href="forum.asp"><%=forumtitle%></a> > 用户登录 </td>
<%else%>
<td><a href="forum_list.asp"><%=forumtitle%></a> > 用户登录 </td>
<%end if%>
<td width="100" align="right"></td>
<td width="10"> </td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td height="20"></td>
</tr>
</table>
<%if bz=2 then%>
<table width="90%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr bgcolor="<%=titlebgcolor%>">
<td height="26" width=30></td>
<td align="center"><b><font color=<%=titlecolor%>>出错信息</font></b></td>
<td> </td>
</tr>
</table>
<table width="90%" border="0" cellspacing="1" cellpadding="0" align="center" bgcolor="<%=tablecolor%>">
<tr bgcolor="#ffffff">
<td width=180 height=30 align=center><font color=ff0000>出错原因可能如下:</font></td>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="2" align="center">
<tr><td height=20>
<li>用户名不正确,或没有此用户名</li>
</td></tr>
<tr><td height=20>
<li>密码不正确</li>
</td></tr>
<%if newuserstate="0" then%>
<tr><td height=20>
<li><font color=ff4500>若是新用户,需等待管理员确认后才能登录!</font></li>
</td></tr>
<%end if%>
<tr><td height=20>
<li>此用户已被系统管理员锁定</li>
</td></tr>
<tr><td height=5></td></tr>
</table>
</td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td height="10"></td>
</tr>
</table>
<%end if%>
<table width="90%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr bgcolor="<%=titlebgcolor%>">
<td height="26" width=30></td>
<td align="center"><b><font color=<%=titlecolor%>>请输入您的用户名、密码登录</font></b></td>
<td> </td>
</tr>
</table>
<table width="90%" border="0" cellspacing="1" cellpadding="0" align="center" bgcolor="<%=tablecolor%>">
<form action="<%=myurl%>" method=post name=editform onsubmit="return checkform(editform)" autocomplete = "off">
<tr bgcolor="#ffffff">
<td width=180 height=30 align=center>输入用户名:</td>
<td>
<input type=text name=usercode size=20 maxlength=20><font color=red size=1>*</font>
<font color="#993300">若没有注册,请<a href="register.asp" class=a01>立即注册</a></font>
</td>
</tr>
<tr bgcolor="#ffffff">
<td width=180 height=30 align=center>输入密码:</td>
<td>
<input type=password name=userpass size=20 maxlength=20><font color=red size=1>*</font>
<font color="#993300">忘记密码,请<a href="#" class=a01>查询密码</a></font>
</td>
</tr>
<tr bgcolor="#ffffff">
<td width=180 height=30 align=center><b>Cookie保存时间:</b><br>
请选择你的 Cookie 保存时间,以便下次访问时不需重新输入登录。
</td>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="2" align="center">
<tr><td height=24>
<input type=radio name=cookieqx value="0" checked>不保存,关闭浏览器就失效
</td></tr>
<tr><td height=24>
<input type=radio name=cookieqx value="1">保存一天
</td></tr>
<tr><td height=24>
<input type=radio name=cookieqx value="2">保存一月
</td></tr>
<tr><td height=24>
<input type=radio name=cookieqx value="3">保存一年
</td></tr>
<tr><td height=5></td></tr>
</table>
</td>
</tr>
<tr bgcolor="#ffffff">
<td width=180 height=30 align=center>登录选项:</td>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="2" align="center">
<tr><td height=24>
<input type=radio name=loginflag value="1" checked>正常登录
</td></tr>
<tr><td height=24>
<input type=radio name=loginflag value="0">隐身登录
<font color="#993300">选择此项登录后将在用户列表看不到您的信息。</font>
</td></tr>
<tr><td height=5></td></tr>
</table>
</td>
</tr>
<tr bgcolor="#e4f4e9">
<td height="40" align="center"><br>
</td>
<td align="left">
<input type="submit" name="submit" value="登 录" style="width:75px; height:24px">
</td>
</tr>
</form>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td height="15"></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<!-- #include file="end.asp" -->
<script language=Javascript>
function checkform(form)
{
var flag=true;
if(form("usercode").value==""){alert("请输入用户名!");form("usercode").focus();return false;}
if(form("userpass").value==""){alert("密码不能为空!");form("userpass").focus();return false;}
return flag;
}
</script>
<%end if%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -