<%@ Language=VBScript %>

' set checking on so that we have to dimension our variables before we can use them
Option Explicit

' dimension our variables first
dim fso, tso, line, line_array, c_username, c_password, username, password, found

' What did the user enter?
username = Request("username")
password = Request("password")

' are the username and password in our list of valid usernames and passwords?

' Create an instance of the FileSystem object
Set fso = CreateObject("Scripting.FileSystemObject")

' Open a TextStream object for our list of valid logins
Set tso = fso.OpenTextFile ("c:\private\users.txt")

found = false

' Search through the contents of the file
do until (tso.AtEndOfStream or found)
	' Read a line of the file
	line = tso.ReadLine

	' Separate the line into username and password
	line_array = Split(line,"|")
	c_username = line_array(0)
	c_password = line_array(1)

	' Do the username and password match what our user entered?
	if (username = c_username) and (password = c_password) then
		' log the user in
		found = true
		Session("logged_in") = "true"
	end if

' Close the text stream

' if we didn't manage to login the user, let them know
if not found then




<p>Sorry we could not find a match for you. Use your browser back button to try again.<p>


	' if we did log them in, then redirect them to the protected pages
	Response.Redirect ("/protected/default.asp")
end if