Log in

View Full Version : Setting up admin levels



Dirt_Diver
01-04-2009, 08:59 PM
I have set up usernames and passwords using php/mysql but no I want to create 4 different levels from site owner with full control to site admin with majority control and users 1 and 2, 2 being the lowest user account.

How would I go about doing this?

Nile
01-04-2009, 09:17 PM
I'd suggest having a field in the user mysql db such as "position."


1 User
2 Moderator
3 Admin
4 Root Admin

Then user would have few permissions such as the normal ones and moderators would have moderator permissions and so on..

If you've got any questions how to code it I'd be glad to help. :)

Dirt_Diver
01-04-2009, 10:13 PM
Yes I would like help on coding it into the site. I just set up the permissions in MySQL as "positions" and assigned them a a number.

Now what?

Nile
01-04-2009, 10:27 PM
Now do something like this:


$query = "SELECT * FROM `table` WHERE `user_id`='{$_GET['id']}'";
$result = mysql_query($query);
while($row = mysql_fetch_assoc($result)){
$queryA = "SELECT * FROM `table` WHERE `position`='{$row[\'position\']}'";
$resultA = mysql_query($query);
while($rowA = mysql_fetch_assoc($resultA)){
if($rowA['positions'] == $row['positions']){
echo "Your position # is ".$rowA['positions'];
}
}
}

To something like that.