<?php

include "../../config/master.php";
allowRoles([1,5]);

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

$data = mysqli_fetch_assoc(mysqli_query($conn,"
SELECT * FROM village_chaupals WHERE id='$id'
"));

if($data)
{

/* DELETE IMAGE */
if(!empty($data['image']))
{
$file = "../../uploads/chaupals/".$data['image'];
if(file_exists($file)){
unlink($file);
}
}

/* DELETE RECORD */
mysqli_query($conn,"DELETE FROM village_chaupals WHERE id='$id'");

}

echo "<script>alert('Chaupal Deleted');window.location='chaupals_list.php';</script>";