<?php
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
    echo "Access Denied";
    exit();
}

include 'config.php';

if(!isset($_POST['id']) || trim($_POST['id']) == '') {
    echo "id is required";
    exit();
}

$sql = "DELETE FROM category WHERE id = ?";

$stmt = $conn->prepare($sql);
if ($stmt) {
    $stmt->bind_param("s", $_POST['id']);

    if ($stmt->execute()) {
        echo "Category Deleted";
    } else {
        echo "Category Delete Failed";
    }
    $stmt->close();
} else {
    echo "Category Delete Failed";
}
$conn->close();
?>