CrazeD Posted February 27, 2007 Share Posted February 27, 2007 I have a clan site that I made and I'm working on an admin area. I want certain people to use their login to access the admin area, while everyone else is restricted. Does anyone know how this can be done? Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted February 27, 2007 Share Posted February 27, 2007 http://www.phpfreaks.com/forums/index.php/topic,113143.0.html Quote Link to comment Share on other sites More sharing options...
CrazeD Posted February 27, 2007 Author Share Posted February 27, 2007 Ok, so would this work? I make a group column in my users table. People sign up, and I go in with my hard-coded admin account and set their group via updating the table. Then make a script to say if group = XX, do this else do this... Would that work? Quote Link to comment Share on other sites More sharing options...
Daleeburg Posted February 27, 2007 Share Posted February 27, 2007 that is exactly what i do, but i only have 2 levels of users, admin "1" or non admin "0". Everybody that signs up automatically gets a "0" (non admin) then using a simple "change user permissions page" i can select a user and change them to admin or not. Then a number is stored in a session and when they go to certain pages it calls that number and checks it if they are admin ...... if they are not ...... If( $_session['admin'] = 1){ echo 'You are and admin'; }else{ echo 'you are a nobody';}; so yes it is just an if else deal. The reason i use the numbering system is that if i want i can make different levels of admin in the future. so i could make a level 2 admin that has more rights, then it would look like If( $_session['admin'] = 1 OR $_session['admin'] = 2 ){ echo 'You are and admin'; }else{ echo 'you are a nobody';}; and now for the really confusing code If( $_session['admin'] = 1 OR $_session['admin'] = 2 ){ If( $_session['admin'] = 2){ echo 'you are a level 2 admin'; }else{ echo 'You are and admin'; }; }else{ echo 'you are a nobody';}; (it is a if else nested in a if else) (there has to be a better way to do that nesting) Quote Link to comment Share on other sites More sharing options...
CrazeD Posted February 27, 2007 Author Share Posted February 27, 2007 Ok, so then on my MySQL table I would have a "group" column and then just have a 0 or 1 in it? (0 for user, 1 for admin) Quote Link to comment Share on other sites More sharing options...
Daleeburg Posted February 27, 2007 Share Posted February 27, 2007 yes Then when the user logs in $_session['group'] = @mysql_result($result, 0, group); then whenever you need to check if they are an admin IF( $_session['group'] == 1){ Whatever you want to happen if they are an admin }ELSE{ Whatever you want to happen if they are not an admin }; Quote Link to comment Share on other sites More sharing options...
CrazeD Posted February 27, 2007 Author Share Posted February 27, 2007 Ok, I'll post back with the problems I'm sure to have. Quote Link to comment 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.