ASP用户登陆系统 登陆后 不能自动跳转index.asp页面
代码:Dim Action
Action=CheckStr(Request.QueryString("Action"))
Select Case Action
Case "savepassword"
Call checkuser()
Call savepassword()
Case "modifypassword"
Call checkuser()
Call ModifyPassWord()
Case "chklogin"
Call chklogin()'-----------------------定义用户登陆界面
Sub chklogin()
if Dreamsun_name<> "" Then response.redirect "index.asp"
%>
<form name="save" method="post" action="user.asp?Action=chklogin" onSubmit="return regcheck(this);">
<br><br>
<table width="600" border=0 align="center" cellPadding=0 cellSpacing=1 class="zd_table" id="form2">
<tr class="zd_td">
<td height="30" align="center" colspan=2><strong>用户登录</strong></td>
</tr>
<tr class="zd_td">
<td width="30%" height="30" align="right"><strong>帐 号:</strong></td>
<td> <input name="username" type="text" id="username" size="20" maxlength="20"> <span id="formct_username"></span></td>
</tr>
<tr class="zd_td">
<td height="30" align="right"><strong>密 码:</strong></td>
<td> <input name="pwd" type="password" id="pwd" size="20" maxlength="20"> <span id="formct_pwd"></span></td>
</tr>
<%If Session(webname&"_logintimes")<>"" Then %>
<tr class="zd_td">
<td height="30" align="right"><strong>验证码:</strong></td>
<td> <input name="zd_code" type="text" id="zd_code" size="4" maxlength="4" onKeyPress="if ((event.keyCode<48 &&event.keyCode!=13) || event.keyCode>57) event.returnValue=false" onFocus="document.all.checkcode.src='inc/GetCode.asp?a=login&s='+Math.random()"/>
<img id='checkcode' src="images/circle.gif" alt= "验证码,看不清楚?请点击刷新验证码" style="cursor : pointer;" onclick="src='inc/GetCode.asp?a=login&s='+Math.random()"/> <span id="formct_zdcode"></span>
</td>
</tr>
<%End If %>
<tr class="zd_td">
<td height="30" align="right"><strong>保留登录:</strong></td>
<td> <input type='radio' name='baoliu' value='' checked>否 <input type='radio' name='baoliu' value='365'>是</td>
</tr>
<tr class="zd_td">
<td height="30" align="right"> </td>
<td><input name="submit3" type=button value='注册' onClick="window.location='user.asp?Action=reg'">
<input name="comurl" type="hidden" id="comurl" value="<%=Cstr(Request.ServerVariables("HTTP_REFERER"))%>">
<input type=submit name=login id=login value="登录" >
</tr>
</table>
<br><br>
</form>
<script language="JavaScript1.2">
function regcheck(formct){
if (formct.username.value=='' ){
formct.username.focus();
document.getElementById("formct_username").innerHTML="<font color=red>帐号不能为空,请填写</font>";
return false;
}
if (formct.pwd.value=='' ){
formct.pwd.focus();
document.getElementById("formct_pwd").innerHTML="<font color=red>密码不能为空,请填写</font>";
return false;
}
<%If Session(webname&"_logintimes")<>"" Then %>
if (formct.zd_code.value=='' ){
formct.zd_code.focus();
document.getElementById("formct_zdcode").innerHTML="<font color=red>验证码不能为空,请填写</font>";
return false;
}
<%end if%>
formct.login.disabled=true;
}
</script>
<%
End Sub
'-----------------------定义用户登陆提交
Sub chklogin()
Dim username,pwd,code,comurl
username=Trim(request.form("username"))
pwd=Trim(request.form("pwd"))
Code=trim(request.form("zd_code"))
comurl=Trim(request.form("comurl"))
baoliu=Trim(Request.Form("baoliu"))
if InStr(username," or ")<>0 or InStr(username,"'")<>0 or InStr(username,"`")<>0 or InStr(username,"=")<>0 _
or InStr(username,"-")<>0 or InStr(username,",")<>0 or InStr(username," and ")<>0 then
Response.Write(BackMsg("用户名含有不可接受的字符",""))
end If
If Session(webname&"_logintimes")="" Then Session(webname&"_logintimes")=0
If Session(webname&"_logintimes")<>0 Then
if cstr(session("GetCode_login"))<>cstr(Code) then
Response.Write(BackMsg("验证码不正确",""))
end if
End If
set rs=server.createobject("adodb.recordset")
sql="select * from "& UserTable &" where username='"&username&"'"
rs.open sql,conn,3,3
if rs.eof then
Call backmsg("用户名或者密码错误!","user.asp")
Session(webname&"_logintimes")=Session(webname&"_logintimes")+1
Response.End
else
If rs("pwd")<>md5(pwd) Then
Call backmsg("用户名 或者 密码错误!","user.asp")
Session(webname&"_logintimes")=Session(webname&"_logintimes")+1
ElseIf rs("isLocked")=1 Then
Call backmsg("您的帐户需要审核,请咨询管理员 \n 请等待管理员审核!","")
ElseIf rs("isLocked")=2 Then
lockedInfo=rs("lockedInfo")
lockedTime=rs("lockedTime")
If InStr(lockedInfo,"|")>0 Then
lockedReason=Split(lockedInfo,"|")(0)
lockedAdmin=Split(lockedInfo,"|")(1)
lockedDay=Split(lockedInfo,"|")(2)
If lockedDay="" Or IsNull(lockedDay) Then lockedDay=30
unlockedTime=dateadd("d",lockedDay,lockedTime)
End If
If DateDiff("d",Now(),unlockedTime)>0 Then
Session("regtime") = Now()
Call backmsg("您的帐户被屏蔽,在【"&unlockedTime&"】之前无法登陆,请咨询管理员\n\n操作人:【"&lockedAdmin&"】操作时间:【"&lockedTime&"】\n\n操作原因:【"&lockedReason&"】","")
Else
rs("isLocked")=0
rs("lockedInfo")="||"
rs.update
Call backmsg("系统正在对您的屏蔽进行解封,请重新登陆即可!","")
End If
Else
userlogin_rnd=dreamsun_rnd(18)
If DateDiff("n",rs("LastLogin"), now())>Sys_loginTime Then 'Sys_loginTime分钟内重复登录不算,config定义。
rs("LoginTimes")=rs("LoginTimes")+1
rs("umoney")=rs("umoney")+Sys_loginMoney
OptTable("insert into [account] (accID,accValue,accFromUser,accToUser,accTime,accReason,accRemark) values("&CStr(GetMaxID("account","accid"))&","&CStr(Sys_loginMoney)&",'"&"系统"&"','"&username&"','"&CStr(Now())&"','登陆送积分','')")
End If
rs("LoginTimes")=rs("LoginTimes")+1
rs("LastLogin")=Now()
rs("CookRnd")=Left(md5(userlogin_rnd),5)&right(md5(userlogin_rnd),5)'给数据库一个登陆的随机码,用来验证登录信息。相当于Session
rs("LoginIP")=reip()
rs.update
Response.Cookies("DreamSun_Post_"&webname)("username")=username
Response.Cookies("DreamSun_Post_"&webname)("rnd")=userlogin_rnd
if baoliu<>"" then Response.Cookies("DreamSun_Post_"&webname).expires=dateadd("d",baoliu,now())
if comurl="" then comurl="index.asp"
'清空验证码Session
session("GetCode_login") = ""
Session(webname&"_logintimes")=""
response.write backmsg("",comurl)
end if
end if
rs.close
set rs=nothing
End Sub
谢谢,我是新手
[解决办法]
首先你要确定你的iis中的【默认网站】-【属性】-【文档】类型中有index.asp,且在最上面
[解决办法]
什么错误提示?
确定逻辑是否正确