<?php

require_once __DIR__ . '/../../auth/verifica.php';
require_once __DIR__ . '/../../config/conexao.php';

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

if($id <= 0){
    header('Location: eventos.php');
    exit;
}

try{

    $stmt = $pdo->prepare("
        DELETE FROM eventos
        WHERE id = :id
    ");

    $stmt->execute([
        'id' => $id
    ]);

}catch(Exception $e){

    die(
        'Erro ao excluir evento: ' .
        $e->getMessage()
    );

}

header('Location: eventos.php');
exit;