<?php
require_once "../includes/auth.php";
require_once "../config/db.php";

$id = isset($_GET['id']) ? intval($_GET['id']) : 0;

if ($id > 0) {
    $stmt = $pdo->prepare("DELETE FROM categories WHERE id=?");
    $stmt->execute([$id]);
    header("Location: categories.php?msg=deleted");
    exit;
} else {
    header("Location: categories.php");
    exit;
}
