asp判断是否登录的代码

2022-09-22    分类: 网站建设

asp怎么判断用户登录呢?如果登录错误,肯定就要显示登录错误信息,而不是错误了也可以登录。

<%
dim admin_username,admin_password
admin_username=trim(request("username"))
admin_password=trim(request("password"))

if admin_username="" or admin_password="" then
response.write "<script>alert(’对不起,用户名和密码不能为空!’);document.location.href=’index.asp’;</script>"
response.end
end if’这里是判断输入是不是为空
%>

<%
set conn = Server.CreateObject("ADODB.Connection")
DBPath = Server.MapPath("db1.mdb")
conn.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & DBPath
Set rs = Server.CreateObject("ADODB.Recordset")
sql="select * from info where Username=’"&admin_username&"’"
rs.open sql,conn,1,1

if not rs.eof then
’这个IF判断的意思是:输入的用户名和数据库里的用户名一致的时候。这是你还要判断输入的密码对不对,是吧?所以就有下面的IF。
if rs("UserPwd")<>admin_password then
response.write "<script>alert(’对不起,密码不正确,请重新输入’);document.location.href=’index.asp’;</script>"
response.end
else
response.redirect "index2.asp"
’密码也对的情况下,就可以登录index2.asp页面了
’一般,你好是还要设置session。这样方便别的页面判断是不是登录了。如
’session("jsusername")=username
’session("jsPassword")=Password
end if
end if
%>
<%
rs.close
set rs=nothing
conn.close
set rs=nothing
%>

分享标题:asp判断是否登录的代码
文章来源:https://www.cdcxhl.com/news31/197031.html

成都网站建设公司_创新互联,为您提供网站建设手机网站建设建站公司响应式网站云服务器品牌网站制作

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

商城网站建设