diff --git a/admin/colors.php b/admin/colors.php index 8a6399e..47434df 100755 --- a/admin/colors.php +++ b/admin/colors.php @@ -3,15 +3,12 @@ include('../inc/check_login.php'); include('../inc/check_admin.php'); require_once '../inc/db.php'; - $message = ''; $message_type = ''; $edit_mode = false; $edit_color = null; -// --- Logik zum Hinzufügen, Bearbeiten und Löschen von Farben --- - -// Aktion Löschen +// --- Löschen --- if (isset($_GET['action']) && $_GET['action'] == 'delete' && isset($_GET['id'])) { $id = $_GET['id']; $stmt = mysqli_prepare($conn, "DELETE FROM colors WHERE id = ?"); @@ -26,7 +23,7 @@ if (isset($_GET['action']) && $_GET['action'] == 'delete' && isset($_GET['id'])) mysqli_stmt_close($stmt); } -// Aktion Bearbeiten (Formular laden) +// --- Bearbeiten --- if (isset($_GET['action']) && $_GET['action'] == 'edit' && isset($_GET['id'])) { $id = $_GET['id']; $stmt = mysqli_prepare($conn, "SELECT id, name, hex_code FROM colors WHERE id = ?"); @@ -38,13 +35,13 @@ if (isset($_GET['action']) && $_GET['action'] == 'edit' && isset($_GET['id'])) { $edit_mode = true; } -// Aktion Hinzufügen oder Speichern (POST) +// --- Hinzufügen / Aktualisieren --- if ($_SERVER["REQUEST_METHOD"] == "POST") { $name = $_POST['name']; $hex_code = $_POST['hex_code']; $id = $_POST['id'] ?? null; - if ($id) { // Update-Logik + if ($id) { $stmt = mysqli_prepare($conn, "UPDATE colors SET name = ?, hex_code = ? WHERE id = ?"); mysqli_stmt_bind_param($stmt, "ssi", $name, $hex_code, $id); if (mysqli_stmt_execute($stmt)) { @@ -55,7 +52,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { $message_type = 'danger'; } mysqli_stmt_close($stmt); - } else { // Insert-Logik + } else { $stmt = mysqli_prepare($conn, "INSERT INTO colors (name, hex_code) VALUES (?, ?)"); mysqli_stmt_bind_param($stmt, "ss", $name, $hex_code); if (mysqli_stmt_execute($stmt)) { @@ -69,7 +66,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { } } -// --- Logik zum Auslesen aller Farben --- +// --- Farben auslesen --- $colors = []; $result = mysqli_query($conn, "SELECT id, name, hex_code FROM colors ORDER BY name"); while ($row = mysqli_fetch_assoc($result)) { @@ -83,38 +80,38 @@ require_once '../inc/header.php';

Farbverwaltung

-