<?php

header('Content-Type: application/json');

?>

<?php require_once '../Connections/cmctrfdb.php'; ?>

<?php require_once '../webassist/mysqli/rsobj.php'; ?>

<?php

$conn = new mysqli($servername, $username, $password, $dbname);

if (isset($_POST['id']))

    $id = $_POST['id'];

// Preparazione della query per prevenire SQL Injection

$stmt = $conn->prepare("DELETE FROM contacts_td WHERE idcontactstd = ?");

$stmt->bind_param("i", $id);

if ($stmt->execute()) {

    echo json_encode(['success' => true]);

} else {

    echo json_encode(['success' => false]);

}

$stmt->close();

?>