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

requireCompanyLogin();

$companyId = $_SESSION['company_id'];
$imageId = $_GET['id'] ?? 0;

$stmt = $pdo->prepare("SELECT * FROM company_images WHERE id = ? AND company_id = ?");
$stmt->execute([$imageId, $companyId]);
$image = $stmt->fetch();

if (!$image) {
    setFlashMessage('error', 'Resim bulunamadı.');
    redirect('profile.php');
}

// Dosyayı sil
deleteImage($image['image_path']);

// Veritabanından sil
$stmt = $pdo->prepare("DELETE FROM company_images WHERE id = ?");
$stmt->execute([$imageId]);

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





