<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
session_start();
session_write_close();
require '../config.php';

if (!isset($_SESSION['user_id'])) {
    header("Location: ../login.php");
    exit;
}

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

if ($card_id > 0) {
    $stmt = $conn->prepare("DELETE FROM id_cards WHERE id = ?");
    $stmt->bind_param("i", $card_id);
    $stmt->execute();
}

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