Script not working

  You are currently not logged in. You can view the forums, but cannot post messages. Log In | Register

26-Mar-09 12:34
I am attempting to use the asp VBscript for passwords. here is the asp script:

<%@ 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")
Set tso = fso.OpenTextFile ("c:\elated_tutorials\asp\password_protection\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
loop

' Close the text stream
tso.Close

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

<head>
<title>Login</title>
</head>

<body>

<h1>Login<h1>

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

</body>

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



for some reason it just comes up in a web page showng me the script. Can anyone help?
Thanx in advance.
27-Mar-09 10:52
Either your server does not support ASP or the file extension is not .asp.



--
Chris.
So long, and thanks for all the fish.
http://webmaster-talk.eu/

 
New posts
Old posts

Follow Elated