<?php
session_start();
$crudpath = $_SESSION['crudpath'];
	include_once 'Database.php';
	include_once 'Post.php';
	include_once 'Database2.php';
include_once 'logging.php';

 // Instantiate DB & connect
  $database = new Database2();
  $db = $database->connect();
  // Instantiate object
  $post = new Post($db);
	require_once 'Database2.php';
	if(ISSET($_REQUEST['id'])){
	 _log('Delete says Record: '.$_REQUEST['id']);	
		$query = "DELETE FROM `events2` WHERE id = '$_REQUEST[id]'";
		$stmt = $db->prepare($query);
		$stmt->execute();
		$conn = null;
_log('Record Deleated...');
_log('----------------------------------------');

 echo "<script>alert('Your Record Has Been Successfully Deleted!');</script>";
    echo "<script>window.location.href='$crudpath';</script>";
    exit;
	}else{
		_log('Delete Record Failed, no record for:'.$_REQUEST[id]);
	}
?>