
<?php 
	$conn = mysqli_connect("49.12.125.236","patiltec_anand","Asd123!@#","patiltec_loginsystem1");
	if(!$conn)
	{
		die(mysqli_error());
	}

	$sql = "SELECT * FROM `postsbyusers` ORDER BY `postsbyusers`.`id` DESC";
	$rs = mysqli_query($conn, $sql);

	if(isset($_GET['id']))
	{
		$selectSql = "select * from postsbyusers where id = ".$_GET['id'];
		$rsSelect = mysqli_query($conn,$selectSql);
		$getRow = mysqli_fetch_assoc($rsSelect);
		
		$getIamgeName = $getRow['image'];
		
		$createDeletePath = "../images/".$getIamgeName;
		$createDeletePath2 = "../images/thumbs/".$getIamgeName;
		
		if(unlink($createDeletePath))
		if(unlink($createDeletePath2))
		{
			$deleteSql = "delete from postsbyusers where id = ".$getRow['id'];
			$rsDelete = mysqli_query($conn, $deleteSql);	
			
			if($rsDelete)
			{
			    echo " <center><h2> <b> Records has been deleted sucessfully </b></h2></center>";
				header("refresh:3; URL=imagedelete2.php");
			}
		}
		else
		{
			$errorMsg = "Unable to delete Image";
		}
	}
?>
 
