How to create a secure page?
Manage. asp
'Logon page.
<% @ Language = VBScript %>
<Html>
<Body>
<Form name = "Login" method = "Post" action = "login. asp">
<Input type = "text" name = "username" size = "20"> User name <br>
<Input type = "password" name = "password" size = "20"> password <br>
<Input type = "submit" name = "btnLogin" value = "login">
</Form>
</Body>
Login. asp
'Verify the username and password entered in the form.
<% @ Language = VBScript %>
<% Response. Buffer = True %>
<Html>
<Body>
<% Session ("allow") = True %>
<%
UserName = Request. Form ("username ")
Password = Request. Form ("password ")
'Capture the form content.
Set MyConn = Server. CreateObject ("ADODB. Connection ")
MyConn. Open "connection string"
SQL = "Select * From tblLogin"
Set RS = MyConn. Execute (SQL)
If UserName = RS ("UserName") AND Password = RS ("Password") Then
'If yes, the page to be protected is displayed.
%>
Bytes ----------------------------------------------------------------------------------------------------------------
'Place the content of the page to be protected.
Bytes ----------------------------------------------------------------------------------------------------------------
<%
Else
Response. Redirect "http://www.intels.net/login.asp"
RS. Close
MyConn. Close
Set RS = Nothing
Set MyConn = Nothing
End If
%>
'If not, return to the logon page and ask the user to log on again.
</Body>
Now, let's do the final application work. Add the following code to the front of the page to be protected:
<% @ Language = VBScript %>
<% Response. Buffer = True %>
<% If session ("allow") = False Then Response. Redirect "manage. asp" %>
Note: For more exciting tutorials, please follow the help houseWebpage Design tutorialTopic,