= 2) {
$del = (int) htmlspecialchars($_GET['del']);
$req = $db->prepare('DELETE FROM admin WHERE id =?');
$req->execute(array($del));
header('Location: gestion_des_acces.php');
}
}
if(isset($_POST['send'])) {
if(isset($_POST['pseudo']) AND !empty($_POST['pseudo']) AND isset($_POST['mdp']) AND !empty($_POST['mdp']) AND isset($_POST['perm']) AND !empty($_POST['perm'])) {
$pseudo = htmlspecialchars($_POST['pseudo']);
$mdp = htmlspecialchars($_POST['mdp']);
$perm = htmlspecialchars($_POST['perm']);
switch ($perm) {
case "v0":
$perm_int = 0;
break;
case "v1":
$perm_int = 1;
break;
case "v2":
$perm_int = 2;
break;
}
if(strlen($pseudo) <= 50) {
$req = $db->prepare("SELECT id FROM admin WHERE pseudo = ?");
$req->execute(array($pseudo));
$pseudo_exist = $req->rowCount();
if ($pseudo_exist == 0) {
$req = $db->prepare("INSERT INTO admin(pseudo, mdp, perm) VALUES(?, ?, ?)");
$req->execute(array($pseudo, password_hash($mdp, PASSWORD_DEFAULT), $perm_int));
header('refresh:0');
} else {
$error = "pseudo déja utilisé";
}
} else {
$error = "le pseudo ne doit pas dépasser 50 char";
}
} else {
$error = "Tout les champs doivent être complétés";
}
}
?>
Admin / Accès
".$error."";
}
?>
ID (db)
| Identifiant
| Perm
| Actions
|
query('SELECT id, pseudo, perm FROM admin');
while($admin = $req->fetch()) {
?>
= $admin['id'] ?> |
= $admin['pseudo'] ?> |
GDA";
break;
case 1:
echo "Bureau";
break;
case 2:
echo "Admin";
break;
}
?> |
X |