Forum Moderators: coopster
I think I am doing this correctly but I can't be because I am getting errors.
I have written a login script which when the correct username and password are entered the
is set to true like that. $_SESSION['Authenticated'] = true
now I have a page I want to be protected so I created a file called auth.php which consists of this...
<?php
session_start()
if($_SESSION['Authenticated']!= true)
{
header('Location: http://mydomain.co.uk/loginform.php');
}
else
{
exit;
}
?>
I am getting the error
Parse error: syntax error, unexpected T_IF in /home/www/juttuffi/auth.php on line 3
I have included the auth.php file at the top of the page i want to be protected, like this
include 'auth.php';
its at the very top of the page so the
[b]session_start();[/b] will work and I really really cant see what the problem could be here so can anyone correct me where I am going wrong with this? I would really appreciate any help or advice at all!
[b]
<?php
session_start();
if($_SESSION['Authenticated']!= true)
{
header('Location: http://mydomain.co.uk/loginform.php');
}
else
{
exit;
}
?>
[/b]
so the way i understand this, if its not true then it will redirect to the loginrequest page otherwise it will exit and continue to load the HTML code?
am i right?
session_start();
if($_SESSION['Authenticated']!= true)
{
header('Location: http://mydomain.co.uk/loginform.php');
exit(); //notice the placement of this
}