asp顯示數據的完整代碼
此代碼展示了從發送過來是數據,接收後判斷數據庫有沒有此數據,然後寫入session、cookie值,最後通過彈窗告訴用戶登錄成功,並跳轉至指定頁面
<%
dim name,pwd
name = request.form("name") //頁面接收傳過來的數據
pwd = request.form("pwd") //同上
set rs = server.createobject("adodb.recordset")
sql = "select * from [user] where [name]='"&&"' and [password]='"&md5(pwd)&"'"
//
rs.open sql,conn,1,1
if rs.eof then
call close_rs //sub程序,關閉實例化數據
call close_conn //關閉數據庫連接
call back("數據不存在!")
else
//判斷是不是管理員級別,如果是,寫入session
if rs("level") = 10 then
session("bdkj") = rs("name")
end if
//寫入cookie數據
response.cookies("bdkj")("user") = rs("name")
//sub程序,跳轉到指定頁面
call location("登錄成功!","index.asp")
end if
%>