asp判斷是否登錄的代碼

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

asp怎么判斷用戶登錄呢?如果登錄錯(cuò)誤,肯定就要顯示登錄錯(cuò)誤信息,而不是錯(cuò)誤了也可以登錄。

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

if admin_username="" or admin_password="" then
response.write ""
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
’這個(gè)IF判斷的意思是:輸入的用戶名和數(shù)據(jù)庫(kù)里的用戶名一致的時(shí)候。這是你還要判斷輸入的密碼對(duì)不對(duì),是吧?所以就有下面的IF。
if rs("UserPwd")<>admin_password then
response.write ""
response.end
else
response.redirect "index2.asp"
’密碼也對(duì)的情況下,就可以登錄index2.asp頁(yè)面了
’一般,你好是還要設(shè)置session。這樣方便別的頁(yè)面判斷是不是登錄了。如
’session("jsusername")=username
’session("jsPassword")=Password
end if
end if
%>
<%
rs.close
set rs=nothing
conn.close
set rs=nothing
%>

網(wǎng)站欄目:asp判斷是否登錄的代碼
標(biāo)題路徑:http://muchs.cn/news/197031.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站維護(hù)、Google、網(wǎng)站設(shè)計(jì)公司、網(wǎng)站建設(shè)、云服務(wù)器、標(biāo)簽優(yōu)化

廣告

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

外貿(mào)網(wǎng)站制作