<?php
include("../dbConnect.php");

$func = $_POST['func'];

switch ($func){

	case "AddPost":
	
		$title = $_POST['title'];
		$desc = $_POST['desc'];
		$date = $_POST['date'];
		$sql = "INSERT INTO `Blogs` (`ID`, `title`, `subtitle`, `desc`, `image`, `date`) VALUES ('', '$title','', '$desc', '','$date')";
		$result=mysqli_query($hookup, $sql);
	
	if($result){
		 $pid = mysqli_insert_id($hookup);
		echo "true~".$pid;		
		die();
	}else{
		echo mysqli_error($hookup);
	}
	break;
		

	case "DeletePost":
	
	$id = $_POST['id'];
	$sql = "DELETE  FROM `Blogs` WHERE `ID` = '$id'";
	$result=mysqli_query($hookup, $sql);
	 
	if($result){	
		echo "true";		
		die();
	}else{
		echo mysqli_error($hookup);
	}
	break;
	
	
}

?>