Click to See Complete Forum and Search --> : Help With Multi Password Users


Demolition_Man
01-27-2003, 10:15 AM
i don't know how to change the passwords and usernames correctly because everytime i try it always gives me an invaild login popup message...but when i set it back to the default passwords and usernames it works fine...what mi doing wrong?

here's the password protection system i downloaded:

http://javascript.internet.com/passwords/multiple-users-source.html

IxxI
01-27-2003, 11:02 AM
Can't tell what you're doing wrong - it works fine for me. How about posting your modified code and i'll see if anything looks wrong.
IxxI

Demolition_Man
01-27-2003, 11:17 AM
<!-- Begin
function Login(){
var done=0;
var username=document.login.username.value;
username=username.toLowerCase();
var password=document.login.password.value;
password=password.toLowerCase();
if (username=="Gutsy" && password=="ec") { window.location="page1.html"; done=1; }
if (username=="Demo" && password=="spaced") { window.location="page2.html"; done=1; }
if (username=="member3" && password=="password3") { window.location="page3.html"; done=1; }
if (done==0) { alert("Invalid login!"); }
}
// End -->

the first 2 i edited

IxxI
01-27-2003, 02:44 PM
I know now why it is, though its not your fault.
Its because you've entered Gutsy and Demo with capital letters in front of them and then typing in the passwords with small letters. This is because the "username=username.toLowerCase();" command is in the wrong place. There are 3 solutions to this problem. 1 type gutsy and demo in in lowercase in your code. 2 type gutsy and demo in with capitalised first letters in your username box. Or 3 change the position of username/password=username/password.toLowerCase(); command. So it looks like this:

function Login(){
var done=0;
var username=document.login.username.value;
var password=document.login.password.value;
if (username=="Gutsy" && password=="ec") username=username.toLowerCase(); password=password.toLowerCase(); { window.location="page1.html"; done=1; }
if (username=="Demo" && password=="spaced") username=username.toLowerCase(); password=password.toLowerCase(); { window.location="page2.html"; done=1; }
if (username=="member3" && password=="password3") username=username.toLowerCase(); password=password.toLowerCase(); { window.location="page3.html"; done=1; }
if (done==0) { alert("Invalid login!"); }
}

Messy I know but it works even if you type everything in capitals.
IxxI

Demolition_Man
01-27-2003, 05:25 PM
ah ha...i should have cough that myself...well i'll get you a beer, it's on me:D

Demolition_Man
01-27-2003, 11:25 PM
oh yeah i have frames on my site and the password protection system is in my right frame...how do i get it to open in my main frame? also how do i get my links to work...for example i put members.htm in the window.location area yet it doesn't come up...i also tried putting members.html but nothing. also (IM DEEPLY SORRY FOR THE CONFUSION) anything works for my password and login name...if i mess up typing in the password or username it still works!

IxxI
01-28-2003, 03:42 AM
Sorry, my fault. Messed up the explanation. When you type in the password in the code it MUST be in lower case, otherwise it will be invalid because the program is trying to convert anything you type in in the boxes into lower case. So you can type in in any case in the boxes but in the code it has to be lower case. Also this code works. Don't know what I was thinking yesterday, sorry:

function Login(){
var done=0;
var username=document.login.username.value.toLowerCase();
var password=document.login.password.value.toLowerCase();
if (username=="gutsy" && password=="ec") { window.location="page1.html"; done=1; }
if (username=="demo" && password=="spaced") { window.location="page2.html"; done=1; }
if (username=="member3" && password=="password3") { window.location="ed.html"; done=1; }
if (done==0) { alert("Invalid login!"); }
}

I'm not too sure about frames - need more time to look at it.
IxxI

IxxI
01-28-2003, 03:44 AM
And the links should now work properly.
IxxI

Demolition_Man
01-28-2003, 02:45 PM
ok thx...no one is perfect so it's no problem that you messed up, we all do