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 5 of 5
  1. #1
    Regular Coder tpeck's Avatar
    Join Date
    Oct 2002
    Location
    Sydney, Australia
    Posts
    820
    Thanks
    43
    Thanked 6 Times in 5 Posts

    enter two variables at page entry prompt

    I don't know how to even begin going about this, but it seems to be a fairly simple request.

    I'm looking for a prompt dialog at a certain page that doesn't check a database for registered users (well that would be nice but is not vital).

    What it would do is ask for two pieces of information (User name and Password if you like) and allow the page to retrieve those two pieces of information and use them as variables within the page.

    If anyone can direct me to a place where something of this kind is discussed, I would be very grateful.

    Thanks,

  • #2
    Regular Coder tpeck's Avatar
    Join Date
    Oct 2002
    Location
    Sydney, Australia
    Posts
    820
    Thanks
    43
    Thanked 6 Times in 5 Posts
    This seems to do one variable:

    <script>
    var whatName=prompt("Please enter your name:","");
    function doName(theName){
    if ((whatName != "")&&(whatName !=null)){
    document.writeln("Hello "+whatName+"!")
    }else{
    document.writeln("Hello!")
    }
    }
    doName(whatName);
    </script>

    ***************************************

    Would it be feasible to change the else statement to block entry to the page if something isn't entered? Like, it just keeps popping up until something is entered or Cancel takes the user somewhere pre-defined?

  • #3
    Regular Coder tpeck's Avatar
    Join Date
    Oct 2002
    Location
    Sydney, Australia
    Posts
    820
    Thanks
    43
    Thanked 6 Times in 5 Posts
    This seems to do much that I wanted in case anyone else was interested:

    <SCRIPT LANGUAGE="JavaScript">
    //
    //Login Script Prompt
    //

    /// Functions() (NON-EDITABLE)

    function LogIn(){
    loggedin=false;
    username="";
    password="";
    username=prompt("Username:","");
    username=username.toLowerCase();
    password=prompt("Password:","");
    password=password.toLowerCase();

    /// Login Names and P-words (EDITABLE)

    if (username=="user001" && password=="1234") {
    loggedin=true;
    window.location="http://nmba.usa.tripod.com";
    }
    if (username=="user002" && password=="1234") {
    loggedin=true;
    window.location="http://nmba.usa.tripod.com";
    }

    /// Alert for incorrect (EDITABLE BUT NOT RECOMENDED)

    if (loggedin==false) {
    alert("Login failed!\n\nPlease supply new credentials.");
    }
    }

    </SCRIPT>

  • #4
    Regular Coder
    Join Date
    May 2005
    Posts
    142
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Bravo!

    I just wanted to thank you for learning something on your own!

    I have noticed that most times the questions posted have been answered in the archives...

    Also, thanks for posting your progress on the solution.

    A few times I have posted a lengthy script only to find out the author fixed the problem, but did not reply...

    -------

    You do realize that if someone clicks "view source" they will be able to see the user names and passwords contained in your script....

  • #5
    Regular Coder tpeck's Avatar
    Join Date
    Oct 2002
    Location
    Sydney, Australia
    Posts
    820
    Thanks
    43
    Thanked 6 Times in 5 Posts
    Well, I didn't want to leave it half hanging... (can't claim I worked it all out either).

    For my purposes, it doesn't matter that the input is insecure; but thanks a lot for pointing it out.

    Actually, in the end I didn't use this method - I settled for a form input method that passed variables to another page.


  •  

    Posting Permissions

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