connect_error) { die("Connection failed: " . $conn->connect_error); } if ($_SERVER['REQUEST_METHOD'] == 'POST') { if (isset($_POST['delete'])) { $id = $_POST['id']; $stmt = $conn->prepare("DELETE FROM users WHERE id = ?"); $stmt->bind_param("i", $id); $stmt->execute(); $stmt->close(); } if (isset($_POST['update'])) { $id = $_POST['id']; $username = $_POST['username']; $admin = isset($_POST['admin']) ? 1 : 0; $stmt = $conn->prepare("UPDATE users SET username = ?, admin = ? WHERE id = ?"); $stmt->bind_param("sii", $username, $admin, $id); $stmt->execute(); $stmt->close(); } } $result = $conn->query("SELECT id, username, admin FROM users"); ?>
ID | Username | Admin | Actions |
---|---|---|---|