diff --git a/htdocs/admin/index.php b/htdocs/admin/index.php index 583bb16..3e96888 100644 --- a/htdocs/admin/index.php +++ b/htdocs/admin/index.php @@ -31,7 +31,12 @@ if (!isset($_SESSION['admin'])) { Gestisci Orario Cambia Password'; + echo 'Cambia Password'; + } + ?> + Gestisci Amministratori'; } ?>
diff --git a/htdocs/admin/changepassword.php b/htdocs/admin/password.php similarity index 100% rename from htdocs/admin/changepassword.php rename to htdocs/admin/password.php diff --git a/htdocs/admin/users.php b/htdocs/admin/users.php new file mode 100644 index 0000000..afa219a --- /dev/null +++ b/htdocs/admin/users.php @@ -0,0 +1,115 @@ +prepare("INSERT INTO admins (username, password) VALUES (?, ?)"); + $stmt->bind_param("ss", $username, $hash); + if ($stmt->execute()) { + $message = "Utente admin aggiunto con successo."; + } else { + $message = "Errore durante l'aggiunta: " . $conn->error; + } + } else { + $message = "Compila tutti i campi."; + } +} + +// Delete admin +if (isset($_GET['delete'])) { + $id = intval($_GET['delete']); + if ($id != 1) { // proteggi super admin + $stmt = $conn->prepare("DELETE FROM admins WHERE id = ?"); + $stmt->bind_param("i", $id); + $stmt->execute(); + $message = "Utente admin rimosso."; + } else { + $message = "Non puoi eliminare il super admin."; + } +} + +// Fetch admins +$result = $conn->query("SELECT id, username FROM admins ORDER BY id ASC"); +?> + + + ++ +
+ + +ID | +Username | +Azione | +
---|---|---|
+ | + | + + Elimina + + Super Admin + + | +