急死我了,我怎么就登录不上呢,帮帮忙吧,小弟在线急等

shf13 2004-07-31 03:06:07
在数据库中username和password字段均为char类型
在运行是总提示:密码错误,请重新登陆!!!
但我输入的用户名和密码都没有错
代码如下:
<%@ language = vbscript%>
<html>
<body>
<%
dim username,password
username = request.form("username")
response.write(username)
if username = "" then
response.redirect "login.htm"
end if
password = request.form("password")
response.write(password)
if password = "" then
response.redirect "login.htm"
end if

Set oret = Server.CreateObject("ADODB.Connection")
oret.Open "sucaidb"
Set ors = Server.CreateObject("adodb.Recordset")
Set ors.ACtiveConnection = oret
ors.cursorlocation=3
ors.open "select * from admin_user where username ='" & username &"'"
if ors.eof then
'数据库无此用户
response.write "<center><b>用户名</b>错误,请<a href = login.htm>重新登陆</a>!!!</center>"&vbcrlf
else
if ors("password").value = password then
session("username") = username
session("loginok") = true
response.redirect "admin.asp"
else
session("username") = ""
session("loginok") = false
response.write "<center><b>密码</b>错误,请<a href=login.htm>重新登陆</a>!!!</center>"&vbcrlf
end if
end if
ors.close
set ors=nothing
oret.close
set oret=nothing
%>
</body>
</html>
...全文
115 点赞 收藏 7
写回复
7 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
aspczlover 2004-07-31
呵呵~
回复
shf13 2004-07-31
解决了,谢谢各位
回复
xzq686 2004-07-31
if ors("password").value = password then'这多了一个value另外把用户和密码用trim()
对于用户名和密码的判断:
dim username,password
username = trim(request.form("username"))
password = trim(request.form("password"))
...
if trim(ors("password")) = password then

回复
xzq686 2004-07-31
if ors.eof then
'数据库无此用户
response.write "<center><b>用户名</b>错误,请<a href = login.htm>重新登陆</a>!!!</center>"&vbcrlf
else
if ors("password").value = password then'这多了一个value另外把用户和密码用trim()
session("username") = username
session("loginok") = true
response.redirect "admin.asp"
else
session("username") = ""
session("loginok") = false
response.write "<center><b>密码</b>错误,请<a href=login.htm>重新登陆</a>!!!</center>"&vbcrlf
end if
end if
回复
3573745 2004-07-31
这是我前面些的用户登陆页面。
首先判别用户,然后在判别密码。自我感觉良好!!
很简单的。
另外就是我不怎么喜欢加注释的。相信你能够看懂。
<!--#include file=conn/conn.asp-->
<!--#include file="md5.asp"-->
<%
dim sql
dim rs
dim username
dim password
username=replace(trim(request("usernm")),"'","")
password=md5(replace(trim(Request("UserPasswd")),"'",""))

set rs=server.createobject("adodb.recordset")
sql="select * from manage where name='"&username&"' "
rs.open sql,conn,1,1
if rs.eof then
response.write "<script language='javascript'>" & VbCRlf
response.write "alert('没有该用户名!');" & VbCrlf
response.write "javascript:window.close();" & vbCrlf
response.write "</script>" & VbCRLF
response.end
elseif rs("pass") <> password then
response.write "<script language='javascript'>" & VbCRlf
response.write "alert('密码错误!');" & VbCrlf
response.write "javascript:window.close();" & vbCrlf
response.write "</script>" & VbCRLF
response.end
else
session("UserNm") = Request("UserNm")
session("userclass")=rs("class")
session("adminid")=rs("id")
response.Redirect "adminmanager.asp"
end if
rs.close
conn.close
%>

回复
bbcbs 2004-07-31
错了!
<%@ language = vbscript%>
<html>
<body>
<%
dim username,password
username = request.form("username")
response.write(username)
if username = "" then
response.redirect "login.htm"
end if
password = request.form("password")
response.write(password)
if password = "" then
response.redirect "login.htm"
end if

Set oret = Server.CreateObject("ADODB.Connection")
oret.Open "sucaidb"
Set ors = Server.CreateObject("adodb.Recordset")
Set ors.ACtiveConnection = oret
ors.cursorlocation=3
ors.open "select * from admin_user where username ='" & username &"' and password='"&password&"'"
if ors.eof then
'数据库无此用户
response.write "<center><b>用户名或密码</b>错误,请<a href = login.htm>重新登陆</a>!!!</center>"&vbcrlf
else
session("username") = username
session("loginok") = true
response.redirect "admin.asp"
end if
</center>"&vbcrlf

ors.close
set ors=nothing
oret.close
set oret=nothing
%>
</body>
</html>
回复
bbcbs 2004-07-31
你可以试着这样写
ors.open "select * from admin_user where username ='" & username &"' and password='"password"'"
回复
发帖
ASP
创建于2007-09-28

2.8w+

社区成员

ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
申请成为版主
帖子事件
创建了帖子
2004-07-31 03:06
社区公告
暂无公告