<?php 
	include"../../connect/db.php";

	function deleteDir($path) {
	    if (empty($path)) { 
	        return false;
	    }
	    return is_file($path) ?
	            @unlink($path) :
	            array_map(__FUNCTION__, glob($path.'/*')) == @rmdir($path);
	}

	if( isset($_POST['email']) ){

		$chap = $_POST['email'];

		$sql = mysqli_query($con,"DELETE FROM beneficiary WHERE email = '$chap' ");

		if( $sql ){

			$path = "../../e-banking/assets/images/beneficiary/".$chap."/";

			if(deleteDir($path)) {
			  	echo "success";
			}
			else{
				echo "error3";
			}

		} 
		else{
			echo "error2";
		}
	}
	else{
		echo "error1";
	}
?>