<?php
include "db.php";

if (isset($_GET['id'])) {

    $id = intval($_GET['id']);

    $sql = "DELETE FROM products WHERE product_id = $id";

    if ($conn->query($sql) === TRUE) {
        header("Location: products.php?deleted=1");
        exit();
    } else {
        echo "Error: " . $conn->error;
    }

} else {
    header("Location: products.php");
    exit();
}
?>