Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Mar 2005
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Read a username and password from a file

    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

  • #2
    Regular Coder
    Join Date
    Aug 2004
    Location
    codegoboom@yahoo.com
    Posts
    999
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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).
    *this message will self destruct in n-seconds*


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •