karatekid36 Posted June 17, 2007 Share Posted June 17, 2007 When a user logs in, I would like to have code that will display certain files if the person is an admin and if they are not, it will display other files. Something like this is what I am after. I know that this code is not really checking to see if the user have the admin status, but I would like to create some code that would say if a person have xxxxxx in the admin column of the user table, display the admin navigation, but if they do not, display the normal navigation. I def know that this is possible, but I am not sure of the right approach. Is making this a query the right thing to do and if so, how should I go about this? if (!isset($_SESSION['admin'])) { include ('./includes/header_admin.html'); } else { include ('./includes/header.html'); }; Thank you. I look forward to your answers. Quote Link to comment https://forums.phpfreaks.com/topic/55901-solved-login-questions/ Share on other sites More sharing options...
MasterACE14 Posted June 17, 2007 Share Posted June 17, 2007 you can Create a field in your database called "authlevel" and then in the header.html you can put in if statements. if(authlevel == 1) { include ('./includes/header_admin.html'); } elseif(authlevel == 0) { include ('./includes/header.html'); }; That should do it then. Regards ACE Quote Link to comment https://forums.phpfreaks.com/topic/55901-solved-login-questions/#findComment-276135 Share on other sites More sharing options...
pocobueno1388 Posted June 17, 2007 Share Posted June 17, 2007 Well, you said you had a column in the database that told whether the user was an admin or not, so why not just use that instead of a session? <?php //I am assuming you have a session that holds a unique ID for the user that is stored in $user_ID $query = mysql_query("SELECT rank FROM users WHERE userID='$user_ID'"); $row = mysql_fetch_assoc($query); if ($row['rank'] == 'admin'){ echo 'You have admin capabilities!'; //This is where you would put the links that the admins could see } else { echo "Your not an admin!'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/55901-solved-login-questions/#findComment-276136 Share on other sites More sharing options...
karatekid36 Posted June 17, 2007 Author Share Posted June 17, 2007 Thank you for your help. I got it to work perfectly. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/55901-solved-login-questions/#findComment-276156 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.