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 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Sep 2004
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Need help for password code

    I have this password code so far but I need to make it so after three wrong tries it will send you to a different page. Can someone please tell me how to make it work. Thanks

    <SCRIPT LANGUAGE="JavaScript">
    <!-- 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=="123" && password=="123") { window.location="privated.htm"; done=1; }
    if (username=="321" && password=="321") { window.location="private.htm"; done=1; }
    if (done==0) { alert("Invalid login!"); }
    if (done==0) { window.location="new_page_3.htm"; done=0; }
    }
    // End -->
    </SCRIPT>

  • #2
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You can try something like this but I do not see the point... anyone can view source and quickly grab the username/password and bypass the entire script...

    Code:
    <script type="text/javascript">
     <!-- Begin //
      var hasTried = 1;
      function Login(form){
        if(form.username.value == 123 && form.password.value == 123){
           form.action = 'privated.htm';
           return true;
        }
        if(form.username.value == 321 && form.password.value == 321){
           form.action = 'private.htm';
           return true;
        }
        else if(hasTried < 3){
           form.username.value = '';
           form.password.value = '';
           alert("Invalid login!");
           form.username.focus();
           hasTried++; 
           return false;
        }
      }
     // End -->
    </script>
    </head>
    
    <body>
    <form method="post" action="new_page_3.htm" onsubmit="return Login(this)">
    USERNAME: <input type="text" name="username">
    PASSWORD: <input type="text" name="password">
    <input type="submit" value="Test">
    </form>
    .....Willy


  •  

    Posting Permissions

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