ACCESS转SQL后,后台无法登录的问题
经过调试,问题代码好像是出去这句:
sql="select * from [Admin] where password='"&password&"' and username='"&username&"'"
每次登录的错误提示是这里:
if rs.bof and rs.eof then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>用户名或密码错误!!!</li>"
也就是说没有检索到数据,郁闷!!
把问题代码中的where语句去掉后可登录,但有些功能实现不了
下面的是相关代码:
dim sql,rs
dim username,password,CheckCode
username=replace(trim(request("username")),"'","")
password=replace(trim(Request("password")),"'","")
CheckCode=replace(trim(Request("CheckCode")),"'","")
if UserName="" then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>用户名不能为空!</li>"
end if
if Password="" then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>密码不能为空!</li>"
end if
if CheckCode="" then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>验证码不能为空!</li>"
end if
if session("CheckCode")="" then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>你登录时间过长,请重新返回登录页面进行登录。</li>"
end if
if CheckCode<>CStr(session("CheckCode")) then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>您输入的确认码和系统产生的不一致,请重新输入。</li>"
end if
if FoundErr<>True then
password=md5(password)
Set rs=Server.CreateObject("ADODB.Recordset")
sql="select * from [Admin] where [password]='"&password&"' and [username]='"&username&"'"
rs.open sql,conn,1,3
'Set rs = Server.CreateObject("ADODB.Recordset")
if rs.bof and rs.eof then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>用户名或密码错误!!!</li>"
else
if password<>rs("Password") then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>用户名或密码错误!!!</li>"
else
rs("LastLoginIP")=Request.ServerVariables("REMOTE_ADDR")
rs("LastLoginTime")=now()
rs("LoginTimes")=rs("LoginTimes")+1
rs.update
session("AdminName")=rs("username")
rs.close
set rs=nothing
call CloseConn()
Response.Redirect "Admin_Index.asp"
end if
end if
rs.close
set rs=nothing
end if
if FoundErr=True then
call WriteErrMsg()
end if
call CloseConn()