Files
aj-portfolio/public/admin/project_delete.php
2025-12-23 13:18:58 +02:00

33 lines
722 B
PHP

<?php
declare(strict_types=1);
require __DIR__ . '/../../includes/bootstrap.php';
require_admin_login();
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
header('Location: /public/admin/projects.php');
exit;
}
if (!csrf_verify($_POST['csrf'] ?? null)) {
flash_set('danger', 'CSRF failed.');
header('Location: /public/admin/projects.php');
exit;
}
$id = (int)($_POST['id'] ?? 0);
if ($id <= 0) {
flash_set('danger', 'Invalid project id.');
header('Location: /public/admin/projects.php');
exit;
}
$st = db()->prepare("DELETE FROM projects WHERE id = ?");
$st->execute([$id]);
flash_set('success', 'Project deleted.');
header('Location: /public/admin/projects.php');
exit;