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
https://forums.phpfreaks.com/topic/250493-checking-for-admin-user/
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.

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.