Jump to content

Checking for admin user


papillonstudios

Recommended Posts

I am trying to check for an admin user to access the admin panel.

 

I have been playing around try different things and this what I have ended up with

 

in my database table I have a column called usergroup and i do the follow to check for admin user.

 

$checkAdmin = mysql_query("SELECT * FROM  `users` WHERE email='$email' , usergroup =  'admin'");

$adminUser = mysql_num_rows($checkAdmin);

if ($adminUser == 0)
{
	echo count($adminUser);
	die ('You do not have permissions to access this area');

}

 

I do the select statement through phpmyadmin and it comes back with one row. which is basically hat i want to check for. I do have a variable called $email which is getting a value from the email cookie.

 

currently $adminUser Return a value of 10.

 

All of the count() functions is for testing purposes only.

Link to comment
Share on other sites

The WHERE clause in the query you posted is invalid (you probably want to use a logical AND between the two terms) and produces an mysql syntax error. It's impossible that the query/php code you posted is returning 10 for $adminUser.

 

Also, since $adminUser is not an array, using count() on it makes no sense.

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.