<?php
require 'inc/auth_check.php';
$id = intval($_GET['id'] ?? 0);
$proj = $mysqli->query("SELECT * FROM projects WHERE id={$id}")->fetch_assoc();
if ($proj) {
    if (!empty($proj['image']) && file_exists(__DIR__ . '/../uploads/projects/' . $proj['image'])) {
        @unlink(__DIR__ . '/../uploads/projects/' . $proj['image']);
    }
    $mysqli->query("DELETE FROM projects WHERE id={$id}");
}
header('Location: projects.php');
exit;
