sp0nge
July 26th, 2008, 02:35 PM
I am trying to learn PHP and have come to research sessions for user authentication. I am at the very beginning of understanding this, and my code is basic, but there is a syntax error (apparently) that I'm not able to identify:
<?php
session_start();
//Check to see if user has logged in with a valid password
if ($_SESSION['auth user']!=1 {
echo "Access Denied.";
exit();
}
?>
Upon calling the file in a browser, I get a parse error on line 4. I tried to diagnose this myself and made a simple change:
<?php
session_start();
//Check to see if user has logged in with a valid password
if ($_SESSION['auth user']!=1
{
echo "Access Denied.";
exit();
}
?>
And then I got the error on line 5. Is the "{" not necessary to contain the instructions for "if"?](*,)
<?php
session_start();
//Check to see if user has logged in with a valid password
if ($_SESSION['auth user']!=1 {
echo "Access Denied.";
exit();
}
?>
Upon calling the file in a browser, I get a parse error on line 4. I tried to diagnose this myself and made a simple change:
<?php
session_start();
//Check to see if user has logged in with a valid password
if ($_SESSION['auth user']!=1
{
echo "Access Denied.";
exit();
}
?>
And then I got the error on line 5. Is the "{" not necessary to contain the instructions for "if"?](*,)