From b599691c2eaa2b6966e5bd71a0a993cf56576dca Mon Sep 17 00:00:00 2001
From: Vichingo455
Date: Thu, 2 Oct 2025 09:17:32 +0200
Subject: [PATCH] Manage users
---
htdocs/admin/index.php | 7 +-
.../{changepassword.php => password.php} | 0
htdocs/admin/users.php | 115 ++++++++++++++++++
3 files changed, 121 insertions(+), 1 deletion(-)
rename htdocs/admin/{changepassword.php => password.php} (100%)
create mode 100644 htdocs/admin/users.php
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");
+?>
+
+
+
+ Gestione Admin
+
+
+
+
+
+
+
+
+
Gestione Amministratori
+
⬅ Torna al Dashboard
+
+
+
+
+
+
+
+
Utenti Attivi
+
+
+
+ ID |
+ Username |
+ Azione |
+
+
+
+ fetch_assoc()): ?>
+
+ |
+ |
+
+
+ Elimina
+
+ Super Admin
+
+ |
+
+
+
+
+
+
Aggiungi Nuovo Admin
+
+
+
+
+