...

View Full Version : Read a username and password from a file



newuser
03-03-2005, 09:43 PM
Hi

I have a personal web site that I would like to restrict access to, and want to save the username and password in a text file (password.txt) what is the best way to read username and password from the file, my code doesn't seem to work, can anyone let me know whats wrong with this:

<SCRIPT LANGUAGE='JavaScript'>

var name='username';
var password='userpassword';

function ReadIt() {
var filename = 'password.txt';
if {
var fso, a, ForReading;
ForReading = 1;
fso = new ActiveXObject('Scripting.FileSystemObject');
file = fso.OpenTextFile(filename, ForReading, false);
var name = file.readline();
var password = file.readline();
file.Close();
location="http://www.theknot.com"
}
else {

alert("Invalid Password")

}

} else { alert("Invalid Name")

}

}

Thanks in advance

codegoboom
03-04-2005, 05:27 AM
JavaScript doesn't directly support this type of action. What you're using there is a scripting runtime object from the Windows Script Host--which is intended for administering operating system tasks (not the internet).



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum