多用户登陆问题……●●●●●●●●●●

wupeipei 2005-04-05 09:17:03
以下代码为多用户登陆,为什么我使用任何用户名,他都显示“无此用户名”
错在哪里,兄弟们帮个忙看一下吧。。。数据库里的数数据为
ID name pass
1 a a
2 b b
3 c c


<%
Dim conn
set conn= Server.CreateObject("adodb.connection")
conn.open "driver={Microsoft Access Driver (*.mdb)};dbq="&server.MapPath("db1.mdb")
exec="select * from book where name='"&request("name")&"'"
Set rs = Server.CreateObject("adodb.RecordSet")
rs.Open exec, Conn, 1, 1

if rs.recordcount=0 then
response.write "无此用户名"
else
if rs("pass")=request("pass") then
response.redirect "ok.asp"
else
response.write "密码出错"
end if
end if
%>
...全文
148 17 打赏 收藏 转发到动态 举报
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
mayisky 2005-04-06
  • 打赏
  • 举报
回复
文本框的name呢
<input type="text" name="name" id="name" >
擒兽 2005-04-05
  • 打赏
  • 举报
回复
估计你问题出在变量传递上。
netbooting 2005-04-05
  • 打赏
  • 举报
回复
exec="select pass from book where name='" & request("name") & "'"

试一下
lstup 2005-04-05
  • 打赏
  • 举报
回复
eof 和bof一起用
lstup 2005-04-05
  • 打赏
  • 举报
回复
不用用rs.recordcount,常出错,用rs.eof吧


if rs.eof and rs.bof then
response.write "无此用户名"
wupeipei 2005-04-05
  • 打赏
  • 举报
回复
楼上的我用过,也是不是,如果用 if not rs.eof then 就会报错
如果用 if rs.eof then 就是同样的结果了。。 显示“无此用户名”
mayisky 2005-04-05
  • 打赏
  • 举报
回复
用 if not rs.eof then
wupeipei 2005-04-05
  • 打赏
  • 举报
回复
可能还不是空格的问题,还是老问题呀。!~!~
mymyal123 2005-04-05
  • 打赏
  • 举报
回复
trim(rs("pass"))=trim(request("pass") )
hbhbhbhbhb1021 2005-04-05
  • 打赏
  • 举报
回复
注意空格问题
hbhbhbhbhb1021 2005-04-05
  • 打赏
  • 举报
回复
你字段类型不会不是var的吧,那样你输入的要
exec="select * from book where name='"&trim(request("name"))&"'"
cuilu 2005-04-05
  • 打赏
  • 举报
回复
你用RESPONSE.WRITE把查询语句显示出来看看,然后贴到查询器中查询一下,是否有结果
kevinnewtec 2005-04-05
  • 打赏
  • 举报
回复
你的那个是不是有什么东西没dim?
kevinnewtec 2005-04-05
  • 打赏
  • 举报
回复
'sql=" select * from guest"
'Response.Write rs.RecordCount
这两句忘了删了
heyong5527 2005-04-05
  • 打赏
  • 举报
回复
if rs.eof then response,write "<script>alert("无此用户名");</script>"
kevinnewtec 2005-04-05
  • 打赏
  • 举报
回复
<%
dim conn,rs,sql,i,connstr
connstr="dbq=" & server.MapPath("mdb/mdb.mdb") & ";driver={microsoft access driver (*.mdb)};"
set conn=server.CreateObject("adodb.connection")
conn.Open connstr
set rs=server.CreateObject("adodb.recordset")
sql="select * from admin where id='" & Request.Form("id") & "'" & " and key='" & Request.Form("key") & "'"
'sql=" select * from guest"
set rs=conn.Execute (sql)
'Response.Write rs.RecordCount
if rs.eof and rs.bof then
response.write "帐户或密码有误!"
response.end
else
%>
xukaisam 2005-04-05
  • 打赏
  • 举报
回复
你的文本框的name呢,是什么呢.

<input type="text" name="name" id="name" >

把上面的这条改一下.
exec="select * from book where name='"&request.form("name")&"'"

28,406

社区成员

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

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