Jump to content

Recommended Posts

I found this simple password protect code online, and I'm wondering if someone can help me modify it.  I need it to accept multiple login/passwords.  Right now it accepts "login" and "password" as the login/password...  can someone show me how to make it accept "login" & "password" AND "login2" & "password2" please???  I'm thinking to the right person this won't be too hard...  thanks for any help!!!

 

<script language="javascript">
function pasuser(form) { if (form.id.value=="login") { if (form.pass.value=="password")
{ location="http://quickonlinetips.com/" } else { alert("Wrong Password") } } else { alert("Wrong Username") } }
</script>
<form name="login">
Username: <input name="id" size="6" type="text"><br>
Password: <input name="pass" size="6" type="password"><br><br>
<input value="Login" onclick="pasuser(this.form)" type="button">
</form>

I strongly advise against doing this, as MrAdam said, you should NEVER do this sort of thing client-side.  But I'm not your mother so here you go...

 

<script language="javascript">
function pasuser(form) { 
  var up = {
    'user1' : 'pass1',
    'user2' : 'pass2',
    'user3' : 'pass3',
    // etc...
  };

  if (typeof(up[form.id.value]) != 'undefined') {
    if (up[form.id.value] == form.pass.value) { 
      document.location="http://quickonlinetips.com/"; 
    } else { 
      alert("Wrong Password"); 
    } 
  } else { 
    alert("Wrong Username"); 
  } 
}
</script>
<form name="login">
Username: <input name="id" size="6" type="text"><br>
Password: <input name="pass" size="6" type="password"><br><br>
<input value="Login" onclick="pasuser(this.form)" type="button">
</form>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.