?? chklogin.asp
字號:
<!--#include file="dbconn.asp"-->
<!--#include file="inc_function.asp"-->
<%
dim username,password '獲取提交過來的用戶名和密碼
dim html1,html2,html3 '出錯提示消息
username=trim(request.form("username"))
password=trim(Request.Form("password"))
'過濾字符:'(單引號)
username=check_login(username)
password=check_login(password)
application("configload")=""
'定義出錯的消息內容
'**************************************
'錯誤處理:
'如果發現錯誤:給予提示,并斷開數據庫連接
sub show_err(msg)
Response.Flush
'定義出錯的消息內容
html1="<html><head><title>出錯提示</title><meta http-equiv='Content-Type' content='text/html; charset=gb2312'></head>"
Response.Write html1
%>
<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
<!--
function window_onunload() {
alert(" \n\n<%=html2%>\n\n");
window.open("login.asp","","width=260,height=150,resizable=no,scrollbars=no,status=no,toolbar=no,menubar=no,location=no");
}
//-->
</SCRIPT>
<body oncontextmenu=self.event.returnValue=false LANGUAGE=javascript onunload="return window_onunload()">
<%
rs.close
conn.close
set rs=nothing
set conn=nothing
back=true
if back=true then
%>
<script language="javascript">
<!--
self.close();
//
//-->
</script>
<%
end if
html3="<p><a href='javascript:history.go(-1)'>點擊此處進行修改</a></p>"
html3=html3&"</td></tr></table></body></html>"
Response.Write html3
end sub
%>
<%
'************************************************
if username="" then
html2="您的用戶名不能為空!"
call show_err(html2)
Response.End
end if
if password="" then
html2="您的密碼不能為空!"
call show_err(html2)
Response.End
end if
set rs=server.createobject("adodb.recordset")
sql="select username,password,nickname,online from userinfor where username='"&username&"' and password='"&password&"'"
on error resume next
rs.open sql,conn,1,3
'Response.Write connstr&"<br>"&sql
'Response.End
if Err.number <> 0 then
html2="訪問數據庫失敗:!"&Err.description
call show_err(html2)
Response.end
end if
'如果取得的記錄數不是1
if rs.RecordCount <> 1 then
html2="您的用戶名或者密碼錯誤!"
call show_err(html2)
Response.end
end if
'出于嚴謹性,這里再次驗證用戶名和密碼的一致性
'一般不用再在這里驗證
if trim(rs("password"))=password then
session("icqlogin")=true
session("icqusername")=username
session("icqnickname")=trim(rs("nickname"))
rs("online")=true
on error resume next
rs.Update
rs.close
conn.close
set rs=nothing
set conn=nothing
if Err.number <> 0 then
Response.Write Err.description
else
response.redirect "mainpre.asp"
end if
%>
<%
else
html2="<p>您的用戶名或者密碼錯誤!</p>"
call show_err(html2)
Response.end
end if
%>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -