<?php

require_once("functions.php");
require_once("db-const.php");
session_start();

$mysqli = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
# check connection
if ($mysqli->connect_errno) {
    echo "<p>MySQL error no {$mysqli->connect_errno} : {$mysqli->connect_error}</p>";
    exit();
}

$id = $_GET['id'];
$name = $_GET['name'];
$page = $_GET['page'];

$folder = "../UploadedPresentations/";


$sql = "DELETE FROM `presentation_table` WHERE `id` LIKE '$id'";


if (file_exists("$folder"."$name")) {
    echo unlink("$folder"."$name");
}

if ($mysqli->query($sql)) {
    redirect_to("../presentations.php?page=$page&msg=supp");
} else {
    echo "<p>MySQL error no {$mysqli->errno} : {$mysqli->error}</p>";
    exit();
}

?>



