<?php
session_start();
if (!isset($_SESSION['admin'])) { header('Location: login.php'); exit; }

require '../conexion.php';

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

// Borrar imágenes asociadas
$stmtImgs = $conn->prepare("DELETE FROM imagenes_propiedades WHERE propiedad_id = ?");
$stmtImgs->bind_param("i",$id);
$stmtImgs->execute();
$stmtImgs->close();

// Borrar propiedad
$stmt = $conn->prepare("DELETE FROM propiedades WHERE id = ?");
$stmt->bind_param("i",$id);
$stmt->execute();
$stmt->close();
$conn->close();

header("Location: admin_propiedades.php?del=ok");
exit;
?>
