I have this Contact Form that only sends the info entered into the 'message' field, but doesn't send any info entered into the 'name' or 'email fields. Any help/suggestions will be appreciated.

<?php
$data = json_decode(file_get_contents("php://input"));
$name = trim($data->name);
$name = str_replace(array("\r", "\n"), array(" ", " "), $name);
$email = filter_var(trim($data->email), FILTER_SANITIZE_EMAIL);
$message = trim($data->message);
if (empty($name) || empty($message) || !filter_var($email, FILTER_VALIDATE_EMAIL)) {
echo "One or more invalid entries. Please try again.";
exit;
}

$to = "support@....com";
$from = "From: contact-form@....com". "\r\n";

if (mail($to, "Customer Inquiry", $message)) {

echo "Thank You. Your message has been sent.";
} else {
echo "An error has occurred and your message could not be sent.";
}
?> 

Here's moe code:

<form id="ajax-contact" method="post">
<table class="table10">
<tr>
<td>
<label for="name">Your Name:</label>
<input id="contact-name" type="text" name="name" required>
</td>
</tr>
</tr>
<tr>
<td>
<label for="email">Your Email Address:</label>
<input id="contact-email" type="email" name="email" required>
</td>
</tr>
<tr>
<td>
<label for="message">Message:</label>
<textarea id="contact-message" type="text" name="message" required></textarea>
</td>
</tr>
<tr>
<td>
<button type="submit">Send</button>
</td>
</table>
</form>


<div id="form-response"></div>


<script>
$(function () {
var form = $("#ajax-contact");
form[0].reset(); 
form.submit(function (event) {
event.preventDefault();
var data = {
"name": $("#contact-name").val(),
"email": $("#contact-email").val(),
"message": $("#contact-message").val()
};
$.ajax({
url: "../contact_form_handle.php", 
data: JSON.stringify(data),
contentType: "application/json; charset=utf-8",
dataType: "text",
type: "POST"})
.done(function (response) {
$("#form-response").text(response);
form[0].reset(); 
})
.fail(function (data) {
if (data.responseText.length) {
$("#form-response").text(data.responseText);
} else {
$("#form-response").text("An error has occurred and your message could not be sent.");
}
})
});
});
</script> 
    $message = trim($data->message . "I didn't want to send any other info, so I didn't add it here!");
      Write a Reply...