Results 1 to 2 of 2

Thread: Help with my script

  1. #1
    Join Date
    Dec 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Red face Help with my script

    Hey guys,
    I'm new around here, and I would like some help.

    This is the code :
    <script language="javascript">
    <!--//
    /*This Script allows people to enter by using a form that asks for a
    UserID and Password*/
    function pasuser(form) {
    if (form.id.value=="VIP") {
    if (form.pass.value=="16320606") {
    location="adminspalace.htm"
    } else {
    alert("Invalid Password")
    }
    } else { alert("Invalid UserID")
    }
    }
    //-->
    </script>
    <form name="login" onsubmit="pasuser(this.form)">
    <span class="style13">Username: </span>
    <input name="id" type="text" size="15">
    <br>
    <span class="style13">Password: </strong></span>
    <input name="pass"type="password" size="15">
    <input type="submit" value="Login">
    </form>


    How would I make this redirect to a different page after an invalid password was entered?

    And is it possible to remove the User ID, option entirely? Can I just have a password option?

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    This script is a horrible idea. Anyone viewing the page's source code can get the password and then enter your adminspalace.htm page. Also, they could just look and see the name of the page and enter it directly into the browser's address bar to navigate to it without filling out the form.

    Server side code should be used for this type of thing.

    That said, this would do as you say you want:

    Code:
    <script type="text/javascript">
    /* This Script allows people to enter by using a form that asks
       for a Password or by viewing the page's source code */
    function passwrd(form){
    	if(form.elements.pass.value === '16320606'){
    		location = 'adminspalace.htm';
    	} else {
    		alert('Invalid Password');
    		location = 'someother.htm';
    	}
    	return false;
    }
    </script>
    <form action="#" name="login" onsubmit="return passwrd(this.form)">
    <div>
    <span class="style13">Password: </span>
    <input name="pass" type="password" size="15">
    <input type="submit" value="Login">
    </div>
    </form>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

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