ASP代码 用户登录问题
<%IfRequestQueryStr("action")="LOGOUT"Thensession("admin")=""session("role")=""Sessio...
<%
If RequestQueryStr("action")="LOGOUT" Then
session("admin")=""
session("role")=""
Session.Abandon
Response.Redirect ("../index.asp")
'Call MessageBox("退出成功","../index.asp")
End If
Dim MyValue
Randomize
MyValue = Int((9999 - 1000 + 1) * Rnd + 1000)
If RequestFormStr("action")="LOGIN" then
admin=RequestFormStr("admin")
password=RequestFormStr("password")
checkcode=RequestFormNum("checkcode")
checkcodeO=RequestFormNum("checkcodeO")
If admin="" Then
Call MessageBox("用户名不能为空!","")
Response.End
End If
If password="" Then
Call MessageBox("密码不能为空!","")
Response.End
End If
If checkcode <> checkcodeO Then
Call MessageBox("验证码不正确!","")
Response.End
End If
'Response.Write md5(password)
'Response.End
Set rs=conn.Execute("Select * From admin Where admin='"& admin &"' and password='"& md5(password) &"'")
If rs.eof And rs.bof Then
Call MessageBox("用户名或密码不正确!","")
Response.End
Else
session("admin")=admin
session("role")=rs("role")
session.timeOut=60
Response.Redirect("index.asp")
End If
End If
%>
奇怪我这样写代码,输入正确的用户和密码后,却跳出“用户或密码不正确”
不知道哪边出错了,请高手帮忙下。
解决方法:在Set rs=conn.Execute("Select * From admin Where admin='"& admin &"' and password='"& md5(password) &"'")前面加response.write "Select * From admin Where admin='"& admin &"' and password='"& md5(password) &"'"
response.end 执行后,把结果放入SQL中。 展开
If RequestQueryStr("action")="LOGOUT" Then
session("admin")=""
session("role")=""
Session.Abandon
Response.Redirect ("../index.asp")
'Call MessageBox("退出成功","../index.asp")
End If
Dim MyValue
Randomize
MyValue = Int((9999 - 1000 + 1) * Rnd + 1000)
If RequestFormStr("action")="LOGIN" then
admin=RequestFormStr("admin")
password=RequestFormStr("password")
checkcode=RequestFormNum("checkcode")
checkcodeO=RequestFormNum("checkcodeO")
If admin="" Then
Call MessageBox("用户名不能为空!","")
Response.End
End If
If password="" Then
Call MessageBox("密码不能为空!","")
Response.End
End If
If checkcode <> checkcodeO Then
Call MessageBox("验证码不正确!","")
Response.End
End If
'Response.Write md5(password)
'Response.End
Set rs=conn.Execute("Select * From admin Where admin='"& admin &"' and password='"& md5(password) &"'")
If rs.eof And rs.bof Then
Call MessageBox("用户名或密码不正确!","")
Response.End
Else
session("admin")=admin
session("role")=rs("role")
session.timeOut=60
Response.Redirect("index.asp")
End If
End If
%>
奇怪我这样写代码,输入正确的用户和密码后,却跳出“用户或密码不正确”
不知道哪边出错了,请高手帮忙下。
解决方法:在Set rs=conn.Execute("Select * From admin Where admin='"& admin &"' and password='"& md5(password) &"'")前面加response.write "Select * From admin Where admin='"& admin &"' and password='"& md5(password) &"'"
response.end 执行后,把结果放入SQL中。 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询