<?php
require_once '../../config/config.php';
require_once '../../includes/auth.php';

requireAdminLogin();

$id = $_GET['id'] ?? 0;

$stmt = $pdo->prepare("SELECT * FROM sliders WHERE id = ?");
$stmt->execute([$id]);
$slider = $stmt->fetch();

if (!$slider) {
    setFlashMessage('error', 'Slider bulunamadı.');
    redirect('index.php');
}

// Resmi sil
if ($slider['image']) {
    $imagePath = str_replace(UPLOAD_URL, UPLOAD_PATH, $slider['image']);
    deleteImage($imagePath);
}

// Slider'ı sil
$stmt = $pdo->prepare("DELETE FROM sliders WHERE id = ?");
$stmt->execute([$id]);

setFlashMessage('success', 'Slider başarıyla silindi.');
redirect('index.php');





