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

Thread: hi im stuck

  1. #1
    New to the CF scene
    Join Date
    Nov 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    hi im stuck

    hi im using an encrypted password script, no problem with the script it works fine and forwards the user to urls, there are 8 passcodes, the problem is that on all but one of the passcodes even thought the code works and forwards user to a url, the ALERT box appears as well, i have in included the code and passcodes below. I obviously only want the alert box to appear upon inncorrect passcode entry. thanks

    Code:
    passcodes
    
    14623
    
    24862
    
    36712
    
    45213
    
    56243
    
    61524
    
    74582
    
    84652
    
    {
    
    
    <script>
    
    
    function submitentry(){
    password = document.password1.password2.value.toLowerCase()
    
    passcode = 1
    for(i = 0; i < password.length; i++) {
    passcode *= password.charCodeAt(i);
    }
    
    //
    if(passcode==350859600)
    //
    {
    window.location="http://www.aaaaaaa.php"}
    
    //
    if(passcode==379501200)
    //
    {
    window.location="http://www.dddddddd.php"}
    
    //
    if(passcode==364618800)
    //
    {
    window.location="http://www.ccccccccccccccccc.php"}
    
    //
    if(passcode==424424000)
    //
    {
    window.location="http://www.bbbbbbbbb.php"}
    
    //
    if(passcode==416707200)
    //
    {
    window.location="http://www.nnnnnnnnnnnnnnnnnnnnn.php"}
    
    //
    if(passcode==393120000)
    //
    {
    window.location="mmmmmmmmmmmmmmmmm.php"}
    
    //
    if(passcode==371101500)
    //
    {
    window.location="http://www.pppppppppppppppppp.php"}
    
    //
    if(passcode==344362200)
    //
    {
    window.location="http://www.kkkkkkkkkkkkk.php"}
    
    else{
    alert("EITHER: Profile set to full private, login to view OR no such user.")}
    }
    </script>
    
    <form name="password1">
    
    <input type="password" name="password2" size="15">
    
    <input type="image" src="searchbutton.png" onClick="submitentry()">
    </form>
    
    
    
    }
    Last edited by WA; 11-03-2011 at 03:01 AM.

  • #2
    Senior Coder alykins's Avatar
    Join Date
    Apr 2011
    Posts
    1,724
    Thanks
    41
    Thanked 191 Times in 190 Posts
    that code is brutal... try this
    Code:
    switch (passcode)
    {
      case 350859600 :
          window.location="http://www.aaaaaaaa.php";
          break;
      case 379501200 :
        window.location="http://www.ddddddddddddd.php";
        break;
      case 364618800 :
        window.location="http://www.ccccccccccccccccc.php";
        break;
    ....
    (and so on and so on until finally at the end you finish with)
    ....
       default :
        alert("EITHER: Profile set to full private, login to view OR no such user.";
        break;
    }
    see how much more readable it is? and should work fine w/o throwing the alert on correct enters...

    on a side note...
    need to change
    <script>
    to
    <script type="text/javascript">

    and also this is for fun right? because anyone can just view your source code, highlight the window.location text and navigate, bypassing your password entry
    (just a thought)

    oh and finally, this should be in the javascript forum

    I code C hash-tag .Net
    Reference: W3C W3CWiki .Net Lib
    Validate: html CSS
    Debug: Chrome FireFox IE


  •  

    Posting Permissions

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