I have tried both real escape string and other php methods but I am not sure I am using them correctly. This code shows my input and then the ajax post, where and how would I preform the sanitation?
Please note there is no data base connection so all the character stripping would have to be done in jQuery somehow.
Would this be more of the correct direction to go in?
<?php
$name = $_POST["name"];
$email = $_POST["email"];
$phone = $_POST["phone"];
$message = $_POST["message"];
$msg = "
Name:$name
Email:$email
Phone:$phone
Comment:
$message";
function checkInput($msg) {
$msg = @strip_tags($msg);
$msg = @stripslashes($msg);
$invalid_characters = array("$", "%", "#", "<", ">", "|");
$msg = str_replace($invalid_characters, "", $msg);
return $msg;
}
$to = "email address";
$subject = "name";
$message = $msg;
$headers = "Contact form enquiry";
mail($to,$subject,$message,$headers);
?>