mardi 30 janvier 2018

PHP Display button if user is an admin

With this piece of code below I receive the users that are an admin from the database. A user is an admin if he has the value '1' in the 'admin' row. So I am only able to get the email addresses from all the admins, but how do I make a button that is only accessible for these admin users, so only they can go to an admin panel.

$admincheck = $db->prepare("SELECT mail From users WHERE admin = 1");          
$admincheck->execute();
$admin = $admincheck->fetchAll(PDO::FETCH_ASSOC);
foreach ($admin as $row) {
     echo $row['mail'];
}

Aucun commentaire:

Enregistrer un commentaire