<?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);

$selectedData = $data->selectedData;

$conn = connect_db();

$res = array();

if ($conn->connect_error) {
	die('Connection failed: ' . $conn->connect_error);
} else {
	$sql = "
		UPDATE `taluomima_submission` 
		SET status = 'pending_deletion' 
		WHERE ID = ?";
	
	if ($stmt = $conn->prepare($sql)) {
		$stmt->bind_param("d", $param_ID);

		$param_ID = $selectedData->id;

		if ($stmt->execute()) {
			array_push($res, array("success" => ""));
		} else {
			array_push($res, array("failed" => ""));
		}
	}
}

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