Wes-Tex - ASP - Password Protect File

<%
Dim thisFile          
' this can be the full HTTP path or just a relative one
' this example uses the relative path
thisFile="default.asp"
               
'These hold the valid usernames and passwords
Dim Username(2)  ' size is to hold 2 items: (0) and (1)
Dim Password(2)

' arrays start at index 0.
Username(0)="john"
Password(0)="jsx"

Username(1)="mike"
Password(1)="aspRules"
%>

<html>
<head>
<title>Password Protected Page</title>
</head>
<body>

<%
' this is used to determine if we find a match for username/password
Dim Matched
Matched=0

Dim i
FOR i = 0 to 1
   If Request.Form("username") = Username(i) And _
      Request.Form("password") = Password(i) Then
     Matched=1
   End If
NEXT

If Matched = 1 Then 
%>

This part of the page is password protected.
<BR>
<a href="<% Response.Write thisFile %>">reload this page with no posted data</a>

<% Else
Response.Write "To view this page, enter a valid Username and Password." & _
"<FORM ACTION=" & thisFile & " METHOD=""POST"">" & _
"Username: <INPUT SIZE=10 TYPE=""text"" NAME=""username"">" & _
"<BR>Password: <INPUT SIZE=10 TYPE=""password"" NAME=""password"">" & _
"<INPUT TYPE=""submit"" NAME=""Submit"" VALUE=""Go"">"  & _
"</FORM>"
End If %>

</body>
</html>