网站的登陆页面的密码验证不起作用
发布网友
发布时间:2022-06-14 07:32
我来回答
共3个回答
热心网友
时间:2023-10-17 18:35
logo 是登陆页 admin是登陆成功后显示的页...
先查询有没有该用户,再对比密码是否正确!!
验证页面:
<!--#include file="conn.asp"-->
<%
dim user,password
user=request.Form("user")
password=request.Form("password")
set rs=server.createobject("adodb.recordset")
sql = "select * from main where user = '"& user &"'"
rs.open sql,conn,1,1
if rs.eof then
response.write("<script language=javascript>alert('不存在的用户名!');")
response.write("this.location.href='logo.asp';</script>")
response.end()
else
if trim(rs("pass"))=trim(password) then
response.Redirect "admin.asp"
else
response.write("<script language=javascript>alert('用户名或密码错误!');")
response.write("this.location.href='logo.asp';</script>")
response.end()
end if
end if
rs.close
%>
热心网友
时间:2023-10-17 18:35
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>检验入口</title>
<!--#include file="conn.asp"-->
<!--#include file="Md5.asp"-->
<%
session.Timeout=999
If CStr(session("GetCode")) <> CStr(request("bootpwd")) Then
response.write "<script LANGUAGE='javascript'>alert('验证码错误!');history.go(-1);</script>"
response.end
End If
dim UserName,UserPwd
UserName = replace(replace(trim(request("username")),chr(34),""),chr(39),"")
UserPwd = md5(trim(request("userpwd")))
sql = "select * from t_admin where UserName='" & UserName & "' and PassWord='" & UserPwd & "'"
Set rs = Server.CreateObject("Adodb.Recordset")
rs.open sql,conn,1,1
if rs.eof Then
response.write "<script LANGUAGE='javascript'>alert('用户名或密码错误!');history.go(-1);</script>"
response.end
else
session("UserName")=trim(rs("UserName"))
session("RealName")=trim(rs("RealName"))
session("Fag")=trim(rs("Fag"))
session("id")=trim(rs("id"))
response.Redirect "list.asp"
end if
rs.close
set rs=nothing
Conn.Close
Set Conn = Nothing
%>
热心网友
时间:2023-10-17 18:36
我觉得你代码里的问题是
if的判断部分
rs.eof 判断游标是否位于最后一条记录之后
为真:没有数据记录
不为真:不一定就是有数据记录
还有,游标若非向前读取,这样判断也会有问题
你改下判断方法试试
if rs.eof then
'错误
else
'登陆成功跳转