<?php include('include/headscript.php');
$conn = new mysqli($servername, $username, $password, $database);
// Ottieni l'ID e il codice univoco dal parametro GET
$hist_id = $_GET['id'];
$uniquecode = $_GET['uniquecode'];

if ($hist_id && $uniquecode) {
    // Cancella il record da hist_rslxls
    $stmt = $conn->prepare("DELETE FROM hist_rslxls WHERE id = ?");
    $stmt->bind_param('i', $hist_id);
    $stmt->execute();

    // Cancella i record correlati da rslxls con lo stesso uniquecode
    $stmt2 = $conn->prepare("DELETE FROM rslxls WHERE uniquecode = ?");
    $stmt2->bind_param('s', $uniquecode);
    $stmt2->execute();

    // Reindirizza dopo la cancellazione
    header("Location: xlstorsl.php?message=deleted");
    exit();
} else {
    echo "Parametri mancanti!";
}
