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.

Link to comment
Share on other sites

$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

 

Link to comment
Share on other sites

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)
}

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.