<?php
// participants_delete.php
require_once __DIR__ . '/../config/db.php';
require_once __DIR__ . '/../config/auth.php';
require_login();

$id = isset($_GET['id']) ? (int)$_GET['id'] : 0;
if (!$id) {
    echo "Invalid participant ID.";
    exit;
}

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $stmt = $pdo->prepare('DELETE FROM participants WHERE id = ?');
    $stmt->execute([$id]);
    header('Location: participants.php');
    exit;
}

$page_title = "Delete Participant";
require_once __DIR__ . "/partials/header.php";
?>
<div class="container py-4">
  <h4>Delete Participant</h4>
  <div class="alert alert-danger">Are you sure you want to delete this participant?</div>
  <form method="post">
    <button type="submit" class="btn btn-danger">Delete</button>
    <a href="participants.php" class="btn btn-secondary">Cancel</a>
  </form>
</div>
<?php require_once __DIR__ . "/partials/footer.php"; ?>
