简单问题求助.

dgrb_BOBO 2006-08-22 09:50:59
自己写的一个验证.问题是:总是提示"密码错误",数据库等都没有问题的了.请教各位高人.

<!--#include file="conn.asp"-->

<%
dim LogName,LogPwd
LogName=trim(request("LogName"))
LogPwd=trim(request("LogPwd"))

if LogName="" or LogPwd="" then
response.write "<script>alert('对不起,用户名和密码不能为空!');document.location.href='login.asp';</script>"
response.end
end if

set rs=server.createobject("adodb.recordset")
sql="select * from Logchk where LogName='"&LogName&"'"
rs.open sql,conn,1,1

%>
<%
if not rs.eof then
if rs("LogPwd")<>LogPwd then
response.write "<script>alert('对不起,密码不正确,请重新输入');document.location.href='login.asp';</script>"
response.end
else
session("user")=LogName
response.redirect "text.asp"
end if
else
response.write "<script>alert('对不起,你的用户名不存在,请与管理员联系!');document.location.href='login.asp';</script>"
response.end
end if

%>
...全文
91 5 打赏 收藏 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
dgrb_BOBO 2006-08-22
  • 打赏
  • 举报
回复
数据库内部没有密码啊。我用户名和密码为空的话可以正确提示“对不起,用户名和密码不能为空”,查询数据库也没有出现问题。密码没有加密。
dh20156 2006-08-22
  • 打赏
  • 举报
回复
1、先把查询语句优化一下:
sql="select Top 1 * From Logchk where LogName='"&LogName&"'";
2、如windtalker1782(风语者)所说,检查数据库内密码是否加密;
jspadmin 2006-08-22
  • 打赏
  • 举报
回复
看上去没什么问题,建议你先把那些判断条件都去掉,直接用最简单的取值后直接从数据库读,然后输出数据库的密码,看看两者是否相同
你也叫风语者 2006-08-22
  • 打赏
  • 举报
回复
rs("LogPwd") 有没有用MD5函数加密?

xzr2004 2006-08-22
  • 打赏
  • 举报
回复
把sql语句输出到数据库中执行下
sql="select * from Logchk where LogName='"&LogName&"'"
Response.Write sql
Response.End()

28,402

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧