<?php
include('db.php');

// Get the phone number from POST
$phoneNumber = $_POST['phoneNumber'] ?? '';

if (!$phoneNumber) {
  echo 'invalid';
  exit;
}

// Sanitize input
$phoneNumber = $conn->real_escape_string($phoneNumber);

// Delete the contact
$sql = "DELETE FROM Contact WHERE from_number = '$phoneNumber'";

if ($conn->query($sql) === TRUE) {
  echo 'success';
} else {
  echo 'error';
}

$conn->close();
?>
