Page 1 of 1

Parse error in a very simple program

Posted: Tue May 06, 2014 4:43 am
by underwood
hi all. i searched and i did find that someone was facing this same problem. Although i did what was told to him, i am still getting the same error. guide me?

i have another php code written for storing username and respective passwords and i have saved it as passwords.php ( if any of this helps y'all)

Error i am getting -
Parse error: syntax error, unexpected 'exist' (T_STRING) in C:\wamp\www\ProjectCms\login.php on line 6

Code: Select all

<?php 
session_start(); 
include("passwords.php"); 
if ($_POST["ac"]=="log") { /// do after login form is submitted  
     if ($USERS[$_POST["username"]]==$_POST["password"]) { /// check if submitted 
     //username and password exist in $USERS array 
          $_SESSION["logged"]=$_POST["username"]; 
     } else { 
          echo'incorrect username/password. Please, try again.'; 
     }; 
}; 
if (array_key_exists($_SESSION["logged"],$USERS)) { //// check if user is logged or not  
     echo "You are logged in."; //// if user is logged show a message  
} else { //// if not logged show login form 
     echo '<form action="login.php" method="post"><input type="hidden" name="ac" value="log"> '; 
     echo 'Username: <input type="text" name="username" />'; 
     echo 'Password: <input type="password" name="password" />'; 
     echo '<input type="submit" value="Login" />'; 
     echo '</form>'; 
}; 
?>

Re: Parse error in a very simple program

Posted: Tue May 06, 2014 10:28 am
by Christopher
It looks like the comment "//username and password exist in $USERS array" is not being parsed as a comment for some reason. Check the file to see why. Test by removing it.

Re: Parse error in a very simple program

Posted: Tue May 06, 2014 11:12 am
by underwood
thanks for the reply christopher.
What you suggested isn't working.
Its still giving me the same error.

Re: Parse error in a very simple program

Posted: Tue May 06, 2014 11:16 am
by Celauran
That's the only instance of 'exist' in that document. It's giving the same error after having removed it?