Forum Moderators: open

Message Too Old, No Replies

Javascript Login Page

creating one. :p

         

danz0r

2:50 am on Jun 9, 2004 (gmt 0)

10+ Year Member



Hi, I'm trying to make a page on my website for people to be able to login to, and then click on a paypal button I put there for them. I've been trying to use a few different methods found here, but I'm not a very good web programmer, and well... yea. :p. I want to use Javascript for now, the information isn't important. I need the script to take the username they put in, then check the password, and if its correct, load a page .com/username.html, using the username they put in. I've been trying to use...

<script type='text/javascript'>

function doSubmit()
{
var s = document.login.username.value;

var p = s.indexOf('@');

var d = s.substring(p + 1, s.length);

var u = s.substring(0, p);

document.login.username.value = u;

document.login.action = 'http://www.website.com/'+d+'.html';

document.login.submit();
}
</script>

<form name="login" method="post" action="">

Username: <input type="text" name="username"><br>

Password: <input type="password" name="password"><br>

<input type="hidden" name="server_id" value="0">

<input type="hidden" name="template" value="style1">

<input type="hidden" name="language" value="en">

<input type='button' value='login' onclick='javascript:doSubmit();'>

and that at least tries to load the username.html, but after that I'm lost, and I have no clue how to make it check the password, and then load that site if its correct, or take them back to the login page if its not. Any help would be appreciated. Thankyou.

Bernard Marx

7:41 am on Jun 9, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There's no real way to check the password client-side without that password itself appearing on the page in some form. One way round it involves the file-name of the destination page being: username_password.htm

The password can be checked against a hashed version. If it's correct, it's concatenated with username, and the page is redirected. Any good?

j4mes

11:19 am on Jun 9, 2004 (gmt 0)

10+ Year Member



There's a pretty impressive Javascript pass here [javascriptkit.com], which redirects to password.htm

HTH

createErrorMsg

12:32 pm on Jun 9, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The really simple version involves renaming the protected page to match your password, then this little function:

function passwordLogin(){
protectedPage = document.theForm.passwordField.value + ".htm";
document.location.href = protectedPage;
return false;
}

Unfortunately, the wrong password results in a Page Not Found error, which doesn't necessarily tell people that they've put in the wrong password, but at least the password isn't IN the script. Actually, the only practical use of this is to make your users feel good because they get to know and use the password.

danz0r

1:57 pm on Jun 9, 2004 (gmt 0)

10+ Year Member



Thank you all very much, I have it figured out now.

Dan.