Use jquery to post your form using ajax and echo the results in php:
Make sure to include jquery:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script type="text/javascript">
$('form').on("submit", function(){
var formData = $(this).serialize();
$.ajax({
type: "POST",
url: "contact_colibri.php",
data: formData,
success: function(result){
$('.feedback').html(result);
}
});
return false;
});
</script>
In your php file make sure you define the $message = "" variable before you try to append any string value:
$message = '';
And you are trying to use the $POST['name'] variable which does not exist and is not checked for either add the name field to your html form or just simply use the email from the form:
either add name in html form:
<input type="text" value="Name" id="name" name="name" class="fields">
or change in php:
$mailHeader="From:".$mailFrom."\nReply-To:".$_POST['email']."<".$mailFrom.">\n";
and now you don't need to set the header locations just echo the feedback:
echo 'Your email did not validate';
echo 'There was a problem sending your email, try again later...
echo 'You did not enter all te required fields';
make sure you add a html element with feedback below your form to show the feedback:
below your form submit button:
<p class="feedback"></p>