我們的目的是:
?。炞C用戶是否經(jīng)過授權(quán)并根據(jù)結(jié)果設置相應的驗證狀態(tài)
?。绻脩羰墙?jīng)過授權(quán)的,驗證狀態(tài)置1
?。绻脩羰菦]有授權(quán)的,驗證狀態(tài)置0
下面顯示的是verify.asp頁的代碼,你可以根據(jù)實際情況作一些相應的修改。
< %
’ Create a command object. This object serves to run our queries
Set Cm = Server.CreateObject(“ADODB.Command”)
’ Specify the system DSN path
Cm.ActiveConnection =“LoginDSN”
’ Now it’s time for the query. We need to check the user information
’ against the table tUsers
Cm.CommandText=“SELECT * FROM tUsers WHERE ”& _
“UserName=’”& Request.Form(“UserName”) &“’ AND ”& _
“UserPassword=’” & Request.Form(“UserPassword”) & “’”
’ Set the query type. 1 means it is a SQL statement
Cm.CommandType = 1
’ Retrieve the results in a recordset object
Set Rs = Cm.Execute
’ We now check if the user is valid. If user is valid, the recordset MUST
’ haverecord. Otherwise it is empty. If user exists, we set authentication
’ status to 1 and send the user to appropriate page, say welcome.asp.
’ Else send the user back to login.asp
If Rs.EOF Then
Session(“Authenticated”) = 0
Response.Redirect (“l(fā)ogin.asp”)
Else
Session(“Authenticated”) = 1
Response.Redirect (“welcome.asp”)
End If
%?。?