' Login page.
<%@ Language=VBScript %>
<html>
<body>
<form name="Login" method="Post" action="">
<input type="text" name="username" size="20">username<br>
<input type="password" name="password" size="20">Password<br>
<input type="submit" name="btnLogin" value="Log in">
</form>
</body></html>
' Verify the username and password entered in the form.
<% = True %>
<html>
<body>
<% Session("allow") = True %>
<%
UserName = ("username")
Password = ("password")
' Crawl form content.
Set MyConn=("")
"Connection string"
SQL = "Select * From tblLogin"
Set RS = (SQL)
If UserName = RS("UserName") AND Password = RS("Password") Then
' If it matches, the page to be protected will be displayed.
%>
----------------------------------------------------------------------------------------------------------------
' Place the content of the page to be protected here.
----------------------------------------------------------------------------------------------------------------
<%
Else
"/"
Set RS = Nothing
Set MyConn = Nothing
End If
%>
' If it does not match, return to the login page,Let the user log in again.
</body></html>
OK, let's do the final application work and add the following code to the front of the page that needs to be protected:
<%@ Language=VBScript %>
<% = True %>
<% If session("allow") = False Then "" %>
[1]