<?php
session_start();
error_reporting(E_ALL ^ (E_NOTICE | E_WARNING));
include"../../../../inc/conn.php";

$id_unit	= str_replace("'","`",(isset($_POST['id_unit'])) ? $_POST['id_unit'] : "");
$id_materi	= str_replace("'","`",(isset($_POST['id_materi'])) ? $_POST['id_materi'] : "");

$q=mysqli_query($connect,"select * from tb_materi where id_materi='".$id_materi."'");
while($r=mysqli_fetch_array($q)){

	$filefoto = $r['file'];
	unlink ("../../../../assets/materi/$filefoto");

 }


$delete1 	= mysqli_query($connect,"delete from tb_materi where id_materi='$id_materi'")or die(mysqli_error($connect));


if($delete1){
	echo"<script>alert('File artikel berhasil dihapus !');</script>";
	echo"<script>document.location.href='index.php?prefix=artikel&unit=$id_unit'</script>";
}else{
	echo"<script>alert('Gagal mengeksekusi perintah ini !');history.go(-1)</script>";
}


?>