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

Thread: Login.php Error

  1. #1
    New to the CF scene
    Join Date
    Jul 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Login.php Error

    I get this error:
    Parse error: syntax error, unexpected $end in C:\Apache2\htdocs\login\index.php on line 38

    For this script:
    PHP Code:
    <html>
    <head>
    <title>
    Login
    </title>
    </head>
    <body>
    <?php
    if(isset($_POST['submit'])) {
    $loggedin FALSE;
    $fp fopen ('users/users.txt''rb');
    while( 
    $line fgetcsv ($fp100"\t")) {
    if((
    $line[0] == $_POST['username'])
    AND(
    $line[1] == crypt($_POST['password1'], $line[1]) ) ) {
    $loggedin TRUE;
    break;
    fclose($fp);

    if(
    $loggedin) {
    print 
    'You are now logged in.';
    }
    else {
    print 
    'The username and the password you entered do not match those on file.';
    }
    } else {
    ?>
    <form action="login.php" method="post">
    Username:<br />
    <input type="text" name="username" size="20"><br />
    Password:<br />
    <input type="password" name="password1" size="20"><br />
    <input type="submit" name="submit" value="Login">
    </form>
    <?php
    }
    ?>
    </body>
    </html>
    If you can fix the script it would be a big help

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,866
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    Count the number of opening and closing brackets- { and }. Proper indenting may help you to solve the issue easily.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Yep, you have 6 opening brackets and only 4 closes. You're while loop is open as is you're isset($_POST['submit']).

    As well, this block in you're while loop:
    PHP Code:
                fclose($fp);

                if(
    $loggedin)
                {
                    print 
    'You are now logged in.';
                }
                else
                {
                    print 
    'The username and the password you entered do not match those on file.';
                } 
    Will never execute. The preceding line has a break call in it terminating you're loop.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)


  •  

    Posting Permissions

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