Initial commit
This commit is contained in:
32
public/admin/project_delete.php
Normal file
32
public/admin/project_delete.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?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;
|
||||
Reference in New Issue
Block a user