Jump to content
Larry Ullman's Book Forums

Ch18- Setting Up Session For User_Level.


Recommended Posts

I am working on chapter 18 and trying to show some pages in the header if the user is admin but it does not show the link for admin.

It just shows links for registered users but not for admin.

 

The code is below:

 

<?php

// Display links based upon the login status:

if(isset($_SESSION['user_id'])) {

echo ' <li> <a href="logout.php" title="Logout">Logout</a> </li>

<li> <a href="change_password.php" title="Change your password"> Change Password</a> </li>';

 

// Show links if the user is admin:

if($_SESSION['user_id'] == 1) {

echo ' <li> <a href="view_users.php" title="View all the users"> View Users </a> </li>

<li> <a href="#" title=" admin page"> admin page</a> </li>';

}

 

} else { // Not logged in.

echo ' <li> <a href="register.php" title="Register for the site"> Register</a> </li>

<li> <a href="login.php" title="Login"> Login </a> </li>

<li> <a href="forgot_password.php" title="Reset password"> Reset Password </a> </li>';

 

}

?>

How can I show the links for the admin?

Note: the admin has got user_level of 1.

Thank you.

Link to comment
Share on other sites

 Share

×
×
  • Create New...