<?php
if(empty($_GET['Kode']))
{
	echo "<b>Data yang dihapus tidak ada</b>";
}
else 
{
	// Membaca Kode dari URL
	$Kode	= $_GET['Kode'];
	$txtNamaFile=$_GET['txtNamaFile'];

	# MENGHAPUS GAMBAR/FOTO, Caranya dengan membaca file gambar
	$mySql = "SELECT * FROM user WHERE id='$Kode'";
	$myQry = mysql_query($mySql, $koneksidb)  or die ("Query salah : ".mysql_error());
	$myData= mysql_fetch_array($myQry);
	if(! $myData['foto']=="") 
	{
		if(file_exists("../foto/".$myData['foto'])) 
		{
					// Jika file gambarnya ada, akan dihapus
			unlink("../foto/".$myData['foto']); 
		}
	}
	$sqlDelete = "DELETE FROM user WHERE id='".$_GET['Kode']."'";
	$qryDelete = mysql_query($sqlDelete, $koneksidb) or die ("Eror hapus data".mysql_error());
	if($qryDelete)
		
	{
		// unlink("../foto/".$txtNamaFile);
		echo "<meta http-equiv='refresh' content='0; url=?page=Data-User&Act=Sucsses'>";
	}
	
}
?>