freemancomputer Posted March 28, 2011 Share Posted March 28, 2011 I just added a user log on for a site I am building using PHP. I used a simple session based system for this. I can log on just fine. What I am looking for is a way to pass on in ht session what rank a user is so some links/pages will only show for the admin or the super user but not the normal user. I rank the users as Admin 1, superuser 2, and user 3. This is what I have for the session in my header that allows you to be logged in. <? session_start(); if(!session_is_registered(myusername)){ header("location:login.php"); } ?> Here is what I have that starts the session //Connection stuff $query="SELECT * FROM user WHERE username='$myusername' and password='$mypassword'"; $result=mysql_query($query); $count=mysql_num_rows($result); if($count==1){ session_register("myusername"); session_register("mypassword"); header("location:index.php"); } else { echo "Wrong Username or Password"; } ob_end_flush(); ?> Link to comment https://forums.phpfreaks.com/topic/231921-adding-diffrent-uer-levels-to-a-page/ Share on other sites More sharing options...
trq Posted March 28, 2011 Share Posted March 28, 2011 Firstly, session_register & session_is_registered have long been deprecated and should no longer be used. You might want to check the manual in regards to how to use sessions. As for your question, as you log your user in, simply store there user level (your already querying for all * a users information yet failing to use what is relevant) within the $_SESSION array and check it whenever required. Link to comment https://forums.phpfreaks.com/topic/231921-adding-diffrent-uer-levels-to-a-page/#findComment-1193152 Share on other sites More sharing options...
freemancomputer Posted March 28, 2011 Author Share Posted March 28, 2011 Thanks I'll take a look. Link to comment https://forums.phpfreaks.com/topic/231921-adding-diffrent-uer-levels-to-a-page/#findComment-1193258 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.