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?
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?
Jump to PostWhen 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.
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.
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.
hi pritaeas can u provide me a sample code for it?
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.