| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 614 人关注过本帖
标题:这段ASP代码为什么不能直接登陆呢?(改。看这个)
只看楼主 加入收藏
d778
Rank: 1
等 级:新手上路
帖 子:257
专家分:0
注 册:2006-1-10
收藏
 问题点数:0 回复次数:4 
这段ASP代码为什么不能直接登陆呢?(改。看这个)

现在通过login.asp文件提交数据到文件login_chenggong.asp
但是他不返回 index.asp首页 却根据cookies 返回到 login.asp
怎样实现 登陆后页面返回 index.asp


下面代码为 login_chenggong.asp
<%
Dim TempPassword
UserName = ReplaceBadChar(Trim(Request("UserName")))
UserPassword=Trim(Request("UserPassword"))
checkcode=ReplaceBadChar(Trim(Request("checkcode")))
CookieDate=ReplaceBadChar(Trim(Request("CookieDate")))
ComeUrl = Trim(Request("ComeUrl"))
If UserPassword="" Then UserPassword= ReplaceBadChar(Trim(Request("Password")))
If ComeUrl = "" Then ComeUrl = Request.ServerVariables("HTTP_REFERER")
if Instr(ComeUrl,"User_Login.asp")>0 Then ComeUrl="User_Index.asp"
if Instr(ComeUrl,"logging.php")>0 Then ComeUrl=Replace( Request.ServerVariables("HTTP_REFERER"),"logging.php?action=login","index.php")
If Instr(ComeUrl,"login.asp")>0 Then ComeUrl=Replace(ComeUrl,"login.asp","")

If UserName = "" Then
FoundErr = True
ErrMsg = ErrMsg & "<br><li>用户名不能为空!</li>"
call WriteErrMsg(ErrMsg)
response.End()
ElseIF Len(UserName)>16 Then
FoundErr = True
ErrMsg = ErrMsg & "<br><li>用户名过长!</li>"
call WriteErrMsg(ErrMsg)
response.End()
Else
UserName = ReplaceBadChar(UserName)
End If
If UserPassword = "" Then
FoundErr = True
ErrMsg = ErrMsg & "<br><li>密码不能为空!</li>"
call WriteErrMsg(ErrMsg)
response.End()
End If
If CookieDate = "" Or (Not IsNumeric(CookieDate)) Then
CookieDate = 0
Else
CookieDate = CLng(CookieDate)
End If

If FoundErr <> True Then'--------A-----Begin
If LoginCheckCode=1 Then
If Request("LoginType")="hl" Then'B----------Begin
CheckCode = LCase(ReplaceBadChar(Trim(Request("CheckCode"))))
If CheckCode = "" Then
FoundErr = True
ErrMsg = ErrMsg & "<br><li>验证码不能为空!</li>"
call WriteErrMsg(ErrMsg)
response.End()
End If
If Trim(Session("CheckCode")) = "" Then
FoundErr = True
ErrMsg = ErrMsg & "<br><li>你登录时间过长,请重新返回登录页面进行登录。</li>"
call WriteErrMsg(ErrMsg)
response.End()
End If
If CheckCode <> Session("CheckCode") Then
FoundErr = True
ErrMsg = ErrMsg & "<br><li>您输入的确认码和系统产生的不一致,请重新输入。</li>"
call WriteErrMsg(ErrMsg)
response.End()
End If
End IF
End if'----------B--------End

Set rs = server.CreateObject("adodb.recordset")
sql = "select top 1 * from hl_user where username='" & UserName & "'"
rs.open sql,conn,1,3
If rs.bof And rs.EOF Then'D------------Begin
FoundErr = True
ErrMsg = ErrMsg & "<br><li>用户名或密码错误1!!!</li>"
call WriteErrMsg(ErrMsg)
response.End()
Else
TempPassword=rs("userpassword")
If Len(TempPassword)=32 Then TempPassword=Mid(TempPassword,9,16)'判断数据库密码是否为32位,是则将密码转为16位
If TempPassword<>Md5(UserPassword,16) Then'将数据库密码跟用户的16位密码相比较'------E---Begin
FoundErr = True
ErrMsg = ErrMsg & "<br><li>用户名或密码错误2!!!</li>"
call WriteErrMsg(ErrMsg)
response.End()
Else
rs("loginIP") = Request.ServerVariables("REMOTE_ADDR")
rs("LastLogin") = Now()
rs("Logins") = rs("Logins") + 1
rs.Update
Select Case CookieDate
Case 0
' not save
Case 1
Response.Cookies(Site_Sn).Expires = Date + 1
Case 2
Response.Cookies(Site_Sn).Expires = Date + 31
Case 3
Response.Cookies(Site_Sn).Expires = Date + 365
End Select
'CookieDate=1
session("hl_user")="hl_user_center"
Response.Cookies("hl_user")("username")=UserName
Response.Cookies("hl_user")("password")=TempPassword
If Domainname<>"" Then Response.Cookies("hl_user").Domain=Domainname
If HLIntegration = False Then'------F----Begin--------
rs.Close
Set rs = Nothing
conn.close
set conn=nothing
Response.redirect ComeUrl
End if'------------------F-------End-------------
Md5Info=MD5(UserName & SecurityKey, 32)
pass=MD5(UserPassword, 32)
pass2=UserPassword
answer=MD5(Answer, 32)

If IsNull(SecurityKey) = False And SecurityKey <> "" And IsNull(arrUpiUrls) = False And arrUpiUrls <> "" Then'H--Begin
HLUpi = Split(arrUpiUrls, "|")
Dim iNum
on error resume next
For iNum = 0 To UBound(HLUpi)
Response.Write "<script src=""" & HLUpi(iNum) & "?action=LoginUser&Md5Info=" & Md5Info & "&name=" & UserName & "&pass=" & pass & "&pass2=" & pass2 & "&answer=" & answer & "&save="&CookieDate&"&usertype="&request("usertype")&"""></script>" & vbCrLf
Response.Write "&nbsp;"
Next
response.Write("<script language=JavaScript>top.location='"&ComeUrl&"';</script>")
End If'---------H-----End

End If'-----E---------End
End If'--------D---------End
rs.Close
Set rs = Nothing
End If'--------A--------End

If FoundErr = True Then
Call WriteErrMsg
End If
conn.close
set conn=nothing
%>

[此贴子已经被作者于2007-4-25 10:39:08编辑过]

搜索更多相关主题的帖子: ASP 代码 登陆 
2007-04-24 15:53
d778
Rank: 1
等 级:新手上路
帖 子:257
专家分:0
注 册:2006-1-10
收藏
得分:0 
帮忙看下!

高手们

2007-04-25 09:48
kidy2005
Rank: 1
等 级:新手上路
帖 子:107
专家分:0
注 册:2007-4-18
收藏
得分:0 
用response.redirect "index.asp"

恒天装饰网:http://www.
2007-04-25 10:23
d778
Rank: 1
等 级:新手上路
帖 子:257
专家分:0
注 册:2006-1-10
收藏
得分:0 
怎么没人啊!

来救救我

2007-04-25 12:40
d778
Rank: 1
等 级:新手上路
帖 子:257
专家分:0
注 册:2006-1-10
收藏
得分:0 
怎么没有人帮忙了?

2007-04-25 17:32
快速回复:这段ASP代码为什么不能直接登陆呢?(改。看这个)
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.027751 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved