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

03-03-2005, 10:43 PM

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:


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();
else {

alert("Invalid Password")


} else { alert("Invalid Name")



Thanks in advance

03-04-2005, 06: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).