asp判斷是否登錄的代碼

2022-09-22    分類: 網(wǎng)站建設(shè)

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判斷的意思是:輸入的用戶名和數(shù)據(jù)庫里的用戶名一致的時候。這是你還要判斷輸入的密碼對不對,是吧?所以就有下面的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頁面了
’一般,你好是還要設(shè)置session。這樣方便別的頁面判斷是不是登錄了。如
’session("jsusername")=username
’session("jsPassword")=Password
end if
end if
%>
<%
rs.close
set rs=nothing
conn.close
set rs=nothing
%>

分享標(biāo)題:asp判斷是否登錄的代碼
文章來源:http://www.muchs.cn/news31/197031.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站建設(shè)、手機(jī)網(wǎng)站建設(shè)、建站公司、響應(yīng)式網(wǎng)站云服務(wù)器、品牌網(wǎng)站制作

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

商城網(wǎng)站建設(shè)