'', 'level' => 0, 'icon' => 'ri-code-s-slash-line']; if ($id) { $st = db()->prepare("SELECT * FROM skills WHERE id = ? LIMIT 1"); $st->execute([$id]); $row = $st->fetch(); if (!$row) { flash_set('danger', 'Skill not found.'); header('Location: /public/admin/skills.php'); exit; } $skill = $row; } $errors = []; if ($_SERVER['REQUEST_METHOD'] === 'POST') { if (!csrf_verify($_POST['csrf'] ?? null)) $errors[] = 'CSRF failed. Refresh and try again.'; $label = trim((string)($_POST['label'] ?? '')); $level = (int)($_POST['level'] ?? 0); $icon = trim((string)($_POST['icon'] ?? '')); if ($label === '' || mb_strlen($label) > 100) $errors[] = 'Label must be 1–100 chars.'; if ($level < 0 || $level > 100) $errors[] = 'Level must be 0–100.'; if ($icon === '' || mb_strlen($icon) > 80) $errors[] = 'Icon must be 1–80 chars (e.g. ri-database-2-line).'; if (!$errors) { if ($id) { $st = db()->prepare("UPDATE skills SET label=?, level=?, icon=? WHERE id=?"); $st->execute([$label, $level, $icon, $id]); flash_set('success', 'Skill updated.'); } else { $st = db()->prepare("INSERT INTO skills(label, level, icon) VALUES (?,?,?)"); $st->execute([$label, $level, $icon]); flash_set('success', 'Skill created.'); } header('Location: /public/admin/skills.php'); exit; } $skill['label'] = $label; $skill['level'] = $level; $skill['icon'] = $icon; } include __DIR__ . '/_top.php'; ?>

Back
Example: ri-database-2-line / ri-code-s-slash-line