PHP (i don't know the problem)

0 Jad Samadi · August 27, 2014
Hi there im a 14 years old guy learning php and while i was trying to make a register/login form thing i had some troubles witch i did not know how to fix it ... please help.


Im having this problem ... it give me error every time i try to open the http://localhost/lr/login.php page ...

error : Parse error: syntax error, unexpected end of file in C:\xampp\htdocs\lr\login.php on line 32

what i have :

<?php

include 'core/init.php';



if (empty($_POST) === false) {

  $username = $_POST['username'];
  $password = $_POST['password'];

 if (empty($username) === true && empty($password) === true) {
   $errors[] = 'You need to enter a username and password';
 }else if (user_exists($username) === false) {
   $errors[] = 'we can\'t find that username. Have you registered ';
 }else if (user_active($username) === false) {
   $errors[] = 'You haven\'t activated your account';
 }else {
        $login = login($username, $password);
        if ($login === false) {
        $errors[] = 'That username or password is incorrect';
        }else {

        // set the user session
        // redirect user to home
    }

  }

  print_r($errors);

?>?

thanks for reading

Post a Reply

Replies

Oldest  Newest  Rating
+2 JOhaL jaTT · August 28, 2014
An error is occurred because you did not close the Curly brackets '{' here if (empty($_POST) === false) {
<?php

include 'core/init.php';



if (empty($_POST) === false) {               // open Curly bracket but was not closed by you..

$username = $_POST['username'];
$password = $_POST['password'];

if (empty($username) === true && empty($password) === true) {
$errors[] = 'You need to enter a username and password';
}
else if (user_exists($username) === false) {
$errors[] = 'we can\'t find that username. Have you registered ';
}
else if (user_active($username) === false) {
$errors[] = 'You haven\'t activated your account';
}
else 
{
$login = login($username, $password);
if ($login === false) {
$errors[] = 'That username or password is incorrect';
}
else
 {

// set the user session
// redirect user to home
}
}
}                //here is the closing Curly bracket which you did not close and got  error 

print_r($errors);

?>
+1 JOhaL jaTT · August 28, 2014
you are welcome mate,  Happy to Help you
0 Eugene Botma · August 28, 2014
The error you get means that it's still looking for something by the time your file ends, thus the end of the file was unexpected. Usually this is because you missed either a bracket, brace or semi-colon somewhere, so I suggest checking each bracket and brace that gets opened and make sure it gets closed as well, and check that every line has a semi-colon (this usually gives another error though)
0 Jad Samadi · August 28, 2014
thanks for the help it worked :D the problem was the last '}' in the end ... thanks
  • 1

PHP

107,313 followers
About

Server-side, HTML embedded scripting language used to create dynamic Web pages.

Links
Moderators