Jump to content

if mysql record is admin, then run a code


Ruko

Recommended Posts

pen and pencil for starters : )

But I  assume you are trying to setup some sort of user level system where for instance unregistered have no level registered have level 1 and admins level 2.

 

Ones you have that you could make if-statements in your script that checks for a certain userlevel and if it does output stuff. Atleast that what i think you are looking for.

$admin = mysql_query("SELECT level FROM users WHERE admin = '¥'") or die(mysql_error());

$array = mysql_fetch_assoc($admin);

 

if ($array['admin'] != '$nonadmins']) {

}

 

Hows that code?

 

Similar to deviantart usernames, for example, im the main admin, my username should be:

¥Ruko

 

Hey Ruko, just a thought.. you will want to use numerics to represent different user levels.

 

regular user = 1

admin = 2

king_kong = 3

 

as far as the error goes, there is an extra "]" bracket in that code

if ($array['level'] == 'admin') {
//do this;
}
else {
//do that;
}

Other than that, his code will work just fine. I would prefer to use the $_POST[''] array to deal with the incoming data from the Db though as follows:

if ($_POST['level'] == 2) {
// you're the admin, go HERE and allow THIS
}
else {
// regular users GO here (use a header re-direct)
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.