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

$id = isset($_GET['id']) ? $_GET['id'] : null;

if($id){

    // opcional: valida se existe antes de excluir
    $sql = "SELECT id FROM pagamentos WHERE id = ?";
    $stmt = $pdo->prepare($sql);
    $stmt->execute([$id]);

    if($stmt->rowCount() > 0){

        $sql = "DELETE FROM pagamentos WHERE id = ?";
        $stmt = $pdo->prepare($sql);
        $stmt->execute([$id]);

    }
}

header("Location: pagamentos.php");
exit;