stevebanks
Programmer
- Mar 30, 2004
- 93
Hey everyone! Hope you can help, I haven't been doing PHP very long, and am trying to do something fairly simple, well, i thought it would be simple, but it doesn't seem to be working
its just a login form going to check a password and change the site's menu to an administrator's menu if it is correct:
my understanding would be that the $_SESSION['loggedin'] would store the value 1.
The page then redirects to the main page where i have:
This seems to change the menu to the admin area when the correct password is entered. But, then when logging out, it doesn't change the $_SESSION("loggedin") to a zero, I have been trying this with the code below, but it won't clear the variable:
This isn't working for some reason???
Does anyone have any ideas please?!?!?
Thanks
Steve
its just a login form going to check a password and change the site's menu to an administrator's menu if it is correct:
Code:
if ($password == "userpass") {
if (! isset($_SESSION['loggedin'])) {
$_SESSION['loggedin'] = 1;
}
header("Location:[URL unfurl="true"]http://www.website.com/index.php");[/URL]
} else {
echo "Your password is incorrect. Please try again";
}
my understanding would be that the $_SESSION['loggedin'] would store the value 1.
The page then redirects to the main page where i have:
Code:
<? if ($_SESSION['loggedin'] = 1) {
?>
<div class="menusubsection">
<p><img src="../images/purplepiece.gif" width="21" height="20" align="left" alt="logo"> <img src="../images/greenpiece.gif" width="21" height="20" align="right" alt="logo"> </p>
<h2>Staff Area </h2>
<p><a href="../app/login.php">Add A New Vacancy</a></p>
<p><a href="../app/vacchangesearch.php">Edit / Archive Current Vacancies</a></p>
<p><a href="../app/logout.php">Log Out </a></p>
<p> </p>
<p><br>
</p></div>
<?
} else { ?>
Different Menu
This seems to change the menu to the admin area when the correct password is entered. But, then when logging out, it doesn't change the $_SESSION("loggedin") to a zero, I have been trying this with the code below, but it won't clear the variable:
Code:
if ( isset($_SESSION['loggedin'])) {
$_SESSION['loggedin'] = 0;
}
header("Location: [URL unfurl="true"]http://www.website.com/index.php");[/URL]
} ?>
This isn't working for some reason???
Does anyone have any ideas please?!?!?
Thanks
Steve