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

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

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

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

 }


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


if($delete1){
	echo"<script>alert('Media berhasil dihapus !');</script>";
	echo"<script>document.location.href='datamedia'</script>";
}else{
	echo"<script>alert('Gagal mengeksekusi perintah ini !');history.go(-1)</script>";
}


?>