<?php require_once('../../db.php'); ?>
<?php 
// if isset post
if ( isset($_POST["id"]) ) {
	try {
		$core = Core::getInstance();
		$stmt = $core->dbh->prepare("DELETE FROM messages WHERE mess_id = :mess_id");
		$stmt -> bindParam("mess_id", $_POST["id"], PDO::PARAM_INT);
		$stmt -> execute();
		$row_count = $stmt -> rowCount();
		if ($row_count > 0) {
			echo "true";
		} else {
			echo "false";
		}
		
		try {
			$core = Core::getInstance();
			$stmt = $core->dbh->prepare("DELETE FROM messages_log WHERE mlog_mess_id = :mess_id");
			$stmt -> bindParam("mess_id", $_POST["id"], PDO::PARAM_INT);
			$stmt -> execute();
		
		} catch(PDOException $pe) {
			trigger_error('Could not connect to MySQL database. ' . $pe->getMessage() , E_USER_ERROR);
		}
		
		
	} catch(PDOException $pe) {
		trigger_error('Could not connect to MySQL database. ' . $pe->getMessage() , E_USER_ERROR);
	}
	
}
?>