prepare("DELETE FROM grievance_updates WHERE grievance_id = ?"); $stmt->execute([$grievance_id]); $stmt = $pdo->prepare("DELETE FROM grievances WHERE id = ?"); $stmt->execute([$grievance_id]); header("Location: index.php"); exit(); } catch (PDOException $e) { // Handle database errors error_log("Database error: " . $e->getMessage()); // You might want to show an error message to the user header("Location: index.php?error=deletion_failed"); exit(); } } else { // Redirect if accessed directly or without a grievance_id header("Location: index.php"); exit(); } ?>