Authenticate. asp
<%
Dim URL
URL = Request. QueryString
'ObtainURL.
%>
<Html>
<Body>
<Form method = post action = "/validate. asp">
<Input type = hidden name = "URL" VALUE = "<% = URL %>">
'SetURLSave to a hidden variable.
User Name:
<Input type = text name = "txtName">
Password:
<Input type = password name = "txtPassword">
<Input type = SUBMIT>
</FORM>
</Body> ReuseValidate. aspFile, read the user name and password from the database to determine whether to authorize the user.
Validate. asp
<%
Dim strUserName, strPassword
StrUserName = Request. form ("txtName ")
StrPassword = Request. form ("txtPassword ")
'Read the username and password from the form.
'Establish Database Connection...
Dim strSQL
StrSQL = "select * from ValidUsers WHERE UserName = "&_
StrUserName & "AND Password = "&_
StrPassword
'ProceedSQLQuery.
Dim rs
Set rs = Conn. Execute (strSQL)
If rs. EOF Then
'IfRecordsetNot empty,The user name is valid..
Session ("bolAuthenticated") = True
'SetBolAuthenticatedSetTrue.
Response. Redirect Request. form ("URL ")
'Pass the userURL.
Else
Response. Redirect "/notvalidated. asp
' Otherwise, the user is not authorized to access , Pass the user to an error prompt page .
End If
%>
[1]