asp登录界面。
时间:2011-09-18
来源:互联网
用asp做了一个网站的登录代码。
<!--#Include file="../func/conn.asp"-->
<%
dim UserName,Password
UserName=trim(request("UserName"))
Password=trim(request("Password"))
if UserName="" then
response.Write(" <script>alert('Your username is blank!');history.go(-1); </script>")
end if
if Password="" then
response.Write(" <script>alert('Your password is blank!');history.go(-1); </script>")
end if
set rs=server.createobject("adodb.recordset")
sql="select * from Admin where UN = '" & UserName & "'"
rs.open sql,conn,1,1
if rs.bof and rs.eof then
rs.close
conn.close
set rs=nothing
set conn=nothing
response.Write(sql)
response.Write(" <script>alert('No such Administrator!');history.go(-1); </script>")
else
if not(password=rs("PW")) then
rs.close
conn.close
set rs=nothing
set conn=nothing
response.Write(" <script>alert('Your password is incorrect!');history.go(-1); </script>")
else
rs.close
conn.close
set rs=nothing
set conn=nothing
response.Write(" <script>window.location.href('AdminManage.asp');</script>")
end if
end if
%>
但是有点问题是,只有第一次可以正确验证。
我测试的时候故意打错密码,它第一次可以正确判断密码不正确。
之后就全部过不了
if rs.bof and rs.eof then
rs.close
conn.close
set rs=nothing
set conn=nothing
response.Write(sql)
response.Write(" <script>alert('No such Administrator!');history.go(-1); </script>")
不管正确与否,都是“No such administrator!”
请问是access不正常推出的问题吗。
<!--#Include file="../func/conn.asp"-->
<%
dim UserName,Password
UserName=trim(request("UserName"))
Password=trim(request("Password"))
if UserName="" then
response.Write(" <script>alert('Your username is blank!');history.go(-1); </script>")
end if
if Password="" then
response.Write(" <script>alert('Your password is blank!');history.go(-1); </script>")
end if
set rs=server.createobject("adodb.recordset")
sql="select * from Admin where UN = '" & UserName & "'"
rs.open sql,conn,1,1
if rs.bof and rs.eof then
rs.close
conn.close
set rs=nothing
set conn=nothing
response.Write(sql)
response.Write(" <script>alert('No such Administrator!');history.go(-1); </script>")
else
if not(password=rs("PW")) then
rs.close
conn.close
set rs=nothing
set conn=nothing
response.Write(" <script>alert('Your password is incorrect!');history.go(-1); </script>")
else
rs.close
conn.close
set rs=nothing
set conn=nothing
response.Write(" <script>window.location.href('AdminManage.asp');</script>")
end if
end if
%>
但是有点问题是,只有第一次可以正确验证。
我测试的时候故意打错密码,它第一次可以正确判断密码不正确。
之后就全部过不了
if rs.bof and rs.eof then
rs.close
conn.close
set rs=nothing
set conn=nothing
response.Write(sql)
response.Write(" <script>alert('No such Administrator!');history.go(-1); </script>")
不管正确与否,都是“No such administrator!”
请问是access不正常推出的问题吗。
作者: johndu81 发布时间: 2011-09-18
将缓存清除后试一试
作者: yaxiya 发布时间: 2011-09-18
不要用 history.go(-1) ,它会缓存上次的数据。
用 Response.Redirect("此网页URL")
用 Response.Redirect("此网页URL")
作者: theforever 发布时间: 2011-09-18
用response.clear吗?还是response.end.
作者: johndu81 发布时间: 2011-09-18
to theforever
改成:
<!--#Include file="../func/conn.asp"-->
<%
dim UserName,Password
UserName=trim(request("UserName"))
Password=trim(request("Password"))
if UserName="" then
response.Write(" <script>alert('Your username is blank!'); </script>")
Response.Redirect("AdminLogin.asp")
end if
if Password="" then
response.Write(" <script>alert('Your password is blank!'); </script>")
Response.Redirect("AdminLogin.asp")
end if
set rs=server.createobject("adodb.recordset")
sql="select * from Admin where UN = '" & UserName & "'"
rs.open sql,conn,1,1
if rs.bof and rs.eof then
rs.close
conn.close
set rs=nothing
set conn=nothing
response.Write(" <script>alert('No such Administrator!'); </script>")
Response.Redirect("AdminLogin.asp")
else
if not(password=rs("PW")) then
rs.close
conn.close
set rs=nothing
set conn=nothing
response.Write(" <script>alert('Your password is incorrect!'); </script>")
Response.Redirect("AdminLogin.asp")
else
rs.close
conn.close
set rs=nothing
set conn=nothing
Response.Redirect("AdminManage.asp")
end if
end if
%>
它不会有提示,直接回到我的登录界面。
改成:
<!--#Include file="../func/conn.asp"-->
<%
dim UserName,Password
UserName=trim(request("UserName"))
Password=trim(request("Password"))
if UserName="" then
response.Write(" <script>alert('Your username is blank!'); </script>")
Response.Redirect("AdminLogin.asp")
end if
if Password="" then
response.Write(" <script>alert('Your password is blank!'); </script>")
Response.Redirect("AdminLogin.asp")
end if
set rs=server.createobject("adodb.recordset")
sql="select * from Admin where UN = '" & UserName & "'"
rs.open sql,conn,1,1
if rs.bof and rs.eof then
rs.close
conn.close
set rs=nothing
set conn=nothing
response.Write(" <script>alert('No such Administrator!'); </script>")
Response.Redirect("AdminLogin.asp")
else
if not(password=rs("PW")) then
rs.close
conn.close
set rs=nothing
set conn=nothing
response.Write(" <script>alert('Your password is incorrect!'); </script>")
Response.Redirect("AdminLogin.asp")
else
rs.close
conn.close
set rs=nothing
set conn=nothing
Response.Redirect("AdminManage.asp")
end if
end if
%>
它不会有提示,直接回到我的登录界面。
作者: johndu81 发布时间: 2011-09-18
ie->常规->internet临时文件:"设置"按钮->选中"每次访问此页时检查"
作者: yaxiya 发布时间: 2011-09-18
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28