Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    May 2006
    Location
    Kingston, WA
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Java Login Script based on PW redirects

    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.

    Follow?

  • #2
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I think you want else if, like so:

    Code:
    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.

  • #3
    New to the CF scene
    Join Date
    May 2006
    Location
    Kingston, WA
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Understand the security.. Thats not really a concern...

    Thanks I'll give this a go.

  • #4
    Regular Coder
    Join Date
    Sep 2005
    Location
    Chicago, IL
    Posts
    160
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    I'm only telling you how I would do it, not how its supposed to be done. ;)

  • #5
    Regular Coder
    Join Date
    Sep 2005
    Location
    Chicago, IL
    Posts
    160
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    <script type="text/javascript">
    function redirectPassword(){
    var password=document.whatever.value;
    document.location.href=password+".html";
    }
    </script>
    I'm only telling you how I would do it, not how its supposed to be done. ;)

  • #6
    New to the CF scene
    Join Date
    May 2006
    Location
    Kingston, WA
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This reloads the same page, it doesn't redirect.. ?? Help..

    <SCRIPT LANGUAGE="JavaScript">
    <!-- Begin
    function Login(){
    var done=0;
    var password=document.login.password.value;
    password=password.toLowerCase();
    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 -->
    </SCRIPT>

  • #7
    New to the CF scene
    Join Date
    May 2006
    Location
    Kingston, WA
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Nevermind... I'm silly!!

    Thanks for everyones help..


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •