Ghamdan Posted October 14, 2012 Share Posted October 14, 2012 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 More sharing options...
Antonio Conte Posted October 14, 2012 Share Posted October 14, 2012 Save the user level to a session too, then compare that instead. 1 Link to comment Share on other sites More sharing options...
Ghamdan Posted October 15, 2012 Author Share Posted October 15, 2012 Thank you. It is working now. Link to comment Share on other sites More sharing options...
Recommended Posts