Jump to content

Please! Help with SIMPLE password protect


kcotter

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>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.