...

View Full Version : Login.php Error



Ev4n
07-25-2008, 07:18 AM
I get this error:
Parse error: syntax error, unexpected $end in C:\Apache2\htdocs\login\index.php on line 38

For this script:

<html>
<head>
<title>
Login
</title>
</head>
<body>
<?php
if(isset($_POST['submit'])) {
$loggedin = FALSE;
$fp = fopen ('users/users.txt', 'rb');
while( $line = fgetcsv ($fp, 100, "\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

abduraooft
07-25-2008, 07:37 AM
Count the number of opening and closing brackets- { and }. Proper indenting may help you to solve the issue easily.

Fou-Lu
07-25-2008, 08:04 AM
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:


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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum