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 3 of 3
  1. #1
    New Coder
    Join Date
    Dec 2006
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Password function error

    Could someone find what the syntax error is. You can see what the script does at mattdsworld.theicy.net/commands/.

    Code:
    <?php
    function requestpass()
    {
    $filename = "./data/pass.txt";
    $handle = fopen($filename, "r");
    $cpass = fread($handle, filesize($filename));
    fclose($handle);
    $pass = $_POST['pass'];
    $pass = md5($pass);
    if (!isset ($_POST['Login'] && $pass != $cpass)) // display form
    {
    ?>
    <form method="POST" action="<?php echo $PHP_SELF; ?>">
    <p>Password: <input type="text" name="pass" size="20"><input type="submit" value="Login" name="Login"></p>
    </form>
    <?php
    }
    else{ // correct password.  Display page.
    }
    ?>
    
    
    <?php
    function requestpassend()
    {
    }
    }
    ?>

  • #2
    Regular Coder anarchy3200's Avatar
    Join Date
    Mar 2003
    Location
    England
    Posts
    261
    Thanks
    0
    Thanked 1 Time in 1 Post
    The line:
    if (!isset ($_POST['Login'] && $pass != $cpass)) // display form
    should be:
    if (!isset($_POST['Login']) && $pass != $cpass) // display form
    Note the moved bracket from the end to after the $_POST['Login']
    Mike

  • #3
    New Coder
    Join Date
    Dec 2006
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts
    TYVM, that fixed the problem. I didn't see that when I added the && != part. I still have a problem, it shows the pass req'd to see this on index:
    Code:
    <?php
    include './scripts/requestpassword.php';
    ?>
    <html>
    <head>
    <title>Thepage</title>
    </head>
    <body>
    <?php requestpass(); ?>
    Pass required to see this.
    <?php requestpassend(); ?>
    </body>
    </html>
    I did fix the main part.
    Last edited by mattd8752; 12-29-2006 at 10:09 PM. Reason: Added something.


  •  

    Posting Permissions

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