Jump to content

How to make permissions?


CrazeD

Recommended Posts

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?

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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

};

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.