asp if循环判断错误

来源:百度知道 编辑:UC知道 时间:2024/05/31 05:28:13
<%
set rs=cnn.execute("select * from userinfo")
if not(rs.eof) then
rs.movenext
if rs("username")=request.form("username") and rs("password")=request.form("password") then
response.Redirect("login.asp")
elseif rs("username")<>request.form("username") then
response.Write"<SCRIPT language=javascript> alert('用户名不正确。');"
response.Write"javascript:history.go(-1)</script>"
elseif rs("username")=request.form("username") and rs("password")<>request.form("password") then
response.Write"<SCRIPT language=javascript> alert('密码不正确。');"
response.Write"javascript:history.go(-1)</script>"
end if
end if
rs.close
set rs=nothing
cnn.close
%>
输入正确的用户名和密码,可以正常运行。但当输入的用户名和密码不正确时,总是提示“用户名不正确”,执行的好像老是第一个

判断来判断去干什么?一次性判断用户名和密码是否正确
<%
set rs=cnn.execute("select * from userinfo where username=request("username") and password=request("password")")
if rs.eof then
response.Write"<script>alert('用户名或密码不正确。');history.go(-1)</script>"
else
session("username")=rs("username")
response.Write"<script>alert('登陆成功!');location='带领客户要去的页面.asp';</script>"
response.end()
end if
rs.close
set rs=nothing
cnn.close
%>

set rs=cnn.execute("select * from userinfo where username ='" & request.form("username") & "'")
if rs.eof then
response.Write"<SCRIPT language=javascript> alert('用户名不正确。');"
response.Write"javascript:history.go(-1)</script>"
else
if rs("password")=request.form("pass