View Full Version : Java Login Script based on PW redirects

05-09-2006, 04:32 AM
I am looking for a simple Java Script that forces a user to put in a password before being able to go into a site. The basic was easy to find, but the problem is, I want to have 2 variables: If the user puts in password 1 it sends them to site A, password 2 sends them to site B. Its simple enough to use an ELSE statement that says if you put in the wrong password it does such, but is there such a thing as an OR statement in between password 1 and wrong password for password 2, or can you use 3 ELSE statements?

I think I'm lost.


05-09-2006, 04:52 AM
I think you want else if, like so:

if( password == 'password1' ){
// redirect to site 1
} else if( password == 'password2' ){
// redirect to site 2
} else {
alert("Incorrect Password");

Remember though, this isn't secure at all.. Someone can just look at the page source and see the passwords.

05-09-2006, 05:26 AM
Understand the security.. Thats not really a concern...

Thanks I'll give this a go.

05-09-2006, 07:01 AM
You could also do that, but use the page name as the password. and put in a redirect like 'document.location.href=password+".html"' or something like that so that if if the page name was yourpage.html they could put in yourpage as the password and be redirected to that page and if the password is wrong they will get the 404 error, its not totally secure but its better than having the password in the source code. Just an idea.

05-09-2006, 07:27 PM
<script type="text/javascript">
function redirectPassword(){
var password=document.whatever.value;

05-10-2006, 11:55 PM
This reloads the same page, it doesn't redirect.. ?? Help..

<!-- Begin
function Login(){
var done=0;
var password=document.login.password.value;
if (password=="wedding") {
window.location="Welcome.htm"; done=1
} else if (password=="party") {
window.location="_Welcome.htm"; done=1;
if (done==0) { alert("Invalid login!"); }
// End -->

05-11-2006, 02:36 AM
Nevermind... I'm silly!! :rolleyes:

Thanks for everyones help.. :thumbsup: