I want to create a menu that displays different links depending on whether users are logged in or not, and whether they are an admin.
I've already managed to create an if statement that displays links based on whether they are logged in or logged out.
I just tried to create another if statement that finds out if the user is an admin. If they are, I want to display additional links.
Here's what I have so far but it's saying I have an undefined variable $a.
if (isset($_SESSION['user_id']) AND (substr($_SERVER['PHP_SELF'], -10) != 'logout.php'))
{
echo '<a href="logout.php">Logout</a><br />
<a href="link.php">link</a><br />';
$query = "SELECT user_id FROM users WHERE admin='$a'";
$result = mysql_query($query);
if (mysql_num_rows($result) == 1)
{
echo '<a href="morelinks.php">more links</a><br />';
}
}
else
{
//Not logged in.
echo '<a href="register.php">Register</a><br />
<a href="login.php">Login</a><br />
<a href="forgot_password.php">Forgot Password</a><br />';
}
My question is what do i need to do to define the variable, and where do i need to put that line?