Hi i need to create a restrictions for the user i have a column "level" which is if the users level is 5 then echo "admin" else if level is 3 echo "mod" and if level is 1 echo "newbie".

How can i do that after they login?

4 Years
Discussion Span
Last Post by ImZick

You could just create an array in the programming side containing the level as key and the lexical of it as value e.g.:
// The level as you got it from db

$level = 3;
$levelLabels = array(1=>"newbie",3=>"mod",5=>"admin"); 
echo $levelLabels[$level];

But … in my point of view the authorities is one distinct table from users. It could have an id and a label on it describing what it is. Of course then you should have an user_authorities table that would be a map of a user Id and an authority Id. So having a users its easy to determine his authorities, not only on “levels” level but in any circumstances your app need different authorities for a specific operation.

Edited by jkon


in my table i have this fields id,email,password,fname,mname,lname,level,territory
users level 5 can only use the registration form.

now in my situatuation if the users login which is a level 5 the users can view the reigstration form else the users can't view this.

but i dont know how to do it I'm totaly new in php and wanted to learn this tools.


When your user logs in, store his information in a session variable. At the top of the registration script, check this session, to see if it contains a valid user (with level 5). If so, output the form, if not, redirect somewhere with an error message.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.