<?php
session_start();
require "../../config/config.php";
if(!isset($_SESSION['admin_username'])){ header("location: ../login.php"); exit; }

$id   = (int)$_GET['id'];
$room = $conn->prepare("SELECT image FROM rooms WHERE id = :id");
$room->execute([':id' => $id]);
$r    = $room->fetch(PDO::FETCH_OBJ);

// Delete image
if($r && $r->image && file_exists('../../images/' . $r->image)){
    unlink('../../images/' . $r->image);
}

$del = $conn->prepare("DELETE FROM rooms WHERE id = :id");
$del->execute([':id' => $id]);

header("location: index.php?success=Room deleted successfully");
exit;
