asp 判断用户问题

来源:百度知道 编辑:UC知道 时间:2024/05/22 13:33:25
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
set conn=Server.createobject("ADODB.connection")
connstr="Provider=Microsoft.Jet.OLEDB.4.0;data source="&server.mappath("data/user.mdb")
conn.open connstr

Set rs=Server.CreateObject("ADODB.Recordset")
sql="select * from [user] where user_name='"&user_name&"' and pwd='"&pwd&"'"
rs.open sql,conn,1,1

if rs.eof and rs.bof then
response.write("验证成功")
else
response.write("验证失败")
end if
rs.close
set rs=nothing
set conn=nothing
%>

大家帮我看下,这段是判断用户的代码,但是我输入错误的还显示验证成功,输入对的也是一样,不知道为什么。。麻烦各位大老看下 小弟感激不尽啊!!!
没给变量赋值!! 现在解决了, 感谢各位。。。

user_name如果是另一个网页传过来的值的话,SQL语句改为
sql="select * from [user] where user_name='"&request("user_name")&"' and pwd='"&request("pwd")&"'"

其次,判断语句,if rs.eof and rs.bof then 改成
if rs.recordcount>0 then
一定能行。

我觉得你这样写比较方便
if not rs.eof then'如果找到了则
response.write("验证成功")
else
response.write("验证失败")
end if

if rs.eof and rs.bof then
response.write("验证失败")
else
response.write("验证成功")