<?php ob_start(); ?>
<?php include_once('includes/header.php'); ?>

<?php

if (isset($_GET['id'])) {
	$ID = clean($_GET['id']);
} else {
	$ID = clean('');
}

if (validateResourceAccess($inputToken)) {

	// get image file from table
	$sql = "SELECT radio_image FROM tbl_radio WHERE id = '$ID'";
	$result = $connect->query($sql);
	$row = $result->fetch_assoc();

	$radio_image = $row['radio_image'];

	// delete data from menu table
	$sql_delete = "DELETE FROM tbl_radio WHERE id = '$ID'";
	$delete = $connect->query($sql_delete);

	// if delete data success
	if ($delete) {
		$filePath = 'upload/'.$radio_image;
		if (file_exists($filePath)) {
			unlink($filePath);
		}
		
		$_SESSION['msg'] = "Radio deleted successfully...";
		header( "Location: radio.php");
		exit;
	}

} else {
	systemUpdateFlag($invalidResponse);
}

?>

<?php include_once('includes/footer.php'); ?>