a text file is such a security risk the code @ http://www.learnasp.com/learn/security.asp does what you want with a Database instead.
At 11:21 AM 7/14/2004, you wrote: >Hi I have been trying to adapt this ASP password script, however I >just can't seem to get it working. Its fairly basic perhaps someone >can figure it out! It is an adaption from the following tutorial > >http://www.elated.com/tutorials/programming/asp/password_protection/ > >However I wanted to set it up so that I could amend the user.txt file >each time I wanted to add a new protected page and not have to play >with the code > >The script is based on a HTML login form, which then runs the >following login.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, landing_page > >' 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 >("/home/freddyfries/public_html/protected/users.txt") >Set tso = fso.OpenTextFile >("/home/freddyfries/public_html/protected/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) >landing_page = line_array(2) > > 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" >exit do >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 >%> > > >Login > >Sorry we could not find a match for you. Use your browser back button to >try again. > > ><% >else > ' if we did log them in, then redirect them to the protected pages > Response.Redirect ("/protected/" & landing_page") >end select >end if >%> > >The text file use the "|" symbols to seperate out the fields. > >If anyone could figure this one out it would be amazing! > > > > > > > > > > > > >Yahoo! Groups Links > > > > > > > > >--- >Incoming mail is certified Virus Free. >Checked by AVG anti-virus system (http://www.grisoft.com). >Version: 6.0.717 / Virus Database: 473 - Release Date: 7/8/2004 ---------- --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.717 / Virus Database: 473 - Release Date: 7/8/2004 [Non-text portions of this message have been removed] ------------------------ Yahoo! Groups Sponsor --------------------~--> Yahoo! Domains - Claim yours for only $14.70 http://us.click.yahoo.com/Z1wmxD/DREIAA/yQLSAA/saFolB/TM --------------------------------------------------------------------~-> Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/AspClassicAnyQuestionIsOk/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
