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

$fullName = $_POST['fullName'] ?? '';
$phoneNumber = $_POST['phoneNumber'] ?? '';
$date_time = date('Y-m-d H:i:s');


if ($fullName && $phoneNumber) {
  $stmt = $conn->prepare("INSERT INTO Contact (name, from_number, date_time) VALUES (?, ?, ?)");
  $stmt->bind_param("sss", $fullName, $phoneNumber, $date_time);

  if ($stmt->execute()) {
    echo "success";
  } else {
    echo "error";
  }

  $stmt->close();
} else {
  echo "Missing fields";
}

$conn ->close();
?>
