<?php
include("connection.php");
ini_set('display_errors', '1');
error_reporting(E_ALL);

if (!isset($_GET['id'])) {
    die("Invalid request: No ID provided.");
}

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

// Optional: Check if the record exists
$result = mysqli_query($con, "SELECT * FROM aluminium WHERE id = $id");
if (mysqli_num_rows($result) == 0) {
    die("Record not found.");
}

// Delete the record
$delete = mysqli_query($con, "DELETE FROM aluminium WHERE id = $id");

if ($delete) {
    header("Location: view_aluminium.php?deleted=1");
    exit();
} else {
    echo "Error deleting record: " . mysqli_error($con);
}
?>

