<?php
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods: POST");

require_once "config.php";

$json = file_get_contents("php://input");
$data = json_decode($json);

$id = $data->ID;

$conn = connect_db();

$res = array();

if ($conn->connect_error) {
	die('Connection failed: ' . $conn->connect_error);
} else {
	$sql = "
		DELETE FROM `submission`
		WHERE ID = " . $id;

	if ($conn->query($sql) === TRUE) {
		$res["success"] = "Delete Successful";
	} else {
		$res["failed"] = "Delete Failed";
	}
}

$conn->close();
echo json_encode($res);
