<?php
require_once('header.php');

if (isset($_GET['id'])) {
    $categoryId = $_GET['id'];

    // Delete the category from the database
    $statement = $pdo->prepare("DELETE FROM tbl_category WHERE id = ?");
    $statement->execute([$categoryId]);

    // Redirect to the category listing page with a success message
    header('Location: category.php?message=Category+deleted+successfully');
    exit;
} else {
    // Redirect to the category listing page with an error message if no ID is provided
    header('Location: category.php?message=Invalid+category+ID');
    exit;
}
?>
