<?php
session_start();
require_once '/home/akgbilis/fi_sf/config.php';
if (!isset($_SESSION['logged_in'])) {
    header("Location: login.php");
    exit;
}


// GET ile gelen combine id
$combineId = $_GET['id'] ?? null;

if (!$combineId) {
    header("Location: combine_dashboard.php");
    exit;
}

try {
    // Önce combine_matches içindeki ilişkileri sil
    $stmt = $pdo->prepare("DELETE FROM combine_matches WHERE combine_id = ?");
    $stmt->execute([$combineId]);

    // Ardından combines tablosundan kuponu sil
    $stmt = $pdo->prepare("DELETE FROM combines WHERE id = ?");
    $stmt->execute([$combineId]);

    header("Location: combine_dashboard.php");
    exit;
} catch (PDOException $e) {
    die("Hata: " . $e->getMessage());
}
?>