connect_error) { die("Connessione fallita: " . $conn->connect_error); } if (!isset($_GET['id']) || !is_numeric($_GET['id'])) { header("Location: riepilogo.php?message=error_delete"); exit(); } $idorder = (int) $_GET['id']; $conn->begin_transaction(); try { // 1. Cancella tutte le prenotazioni di questo ordine $stmt1 = $conn->prepare("DELETE FROM bookingclass WHERE idorder = ?"); $stmt1->bind_param("i", $idorder); $stmt1->execute(); $stmt1->close(); // 2. Cancella l'ordine $stmt2 = $conn->prepare("DELETE FROM orderbook WHERE idorderbook = ?"); $stmt2->bind_param("i", $idorder); $stmt2->execute(); $stmt2->close(); $conn->commit(); header("Location: riepilogo.php?message=success_delete"); exit(); } catch (Exception $e) { $conn->rollback(); header("Location: riepilogo.php?message=error_delete"); exit(); } $conn->close();