<?php

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

$id = intval($_GET['id'] ?? 0);

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

if($data){

/* DELETE IMAGE */

if(!empty($data['image'])){
$file = "../../assets/schemes/".$data['image'];
if(file_exists($file)){
unlink($file);
}
}

/* DELETE RECORD */

mysqli_query($conn,"DELETE FROM schemes WHERE id='$id'");

}

header("Location: view_schemes.php");
exit;
?>