I have this php file that processes Form field entries. Apparently I need to modify it, I’m told, to “validate the input and then send some response back”:
<?php
if($_POST){
$to = '[email protected]';
$subject = 'Thank you for your info';
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$message1 = $_POST['message'];
$headers = $name;
$headers = 'from: [email protected]';
$message1 .= "\r\n\r\nName: ".$_POST['name']." \r\n Email: ".$_POST['email']." ";
$message = "Hello {$_POST['name']}, ~ Thank you for your input\r\n\r\n";
mail( $to, $subject, $message1, $headers );
mail( $email, $subject, $message, $headers );
header('Location: https://....');
exit;
}
?>
The corresponding js looks like this:
var myConfirm;
$(document).ready(function() {
myConfirm = new jBox('Confirm', {
content: $('.my-jbox-form'),
width: 830,
height: 205,
cancelButton: 'Return Home',
confirmButton: 'Continue',
closeOnConfirm: false,
closeOnEsc: false,
confirm: function() {
$.ajax({
url: 'https://...../submit.php',
method: 'post',
data: {
name: $('#name').val(),
email: $('#email').val()
},
success: function (response) {
console.log(response);
if (response.success) {
alert('Success');
} else {
alert('Error');
}
}
});
Any guidance with validating the input and then sending some response back, will be appreciated.