$(document).ready(function(){
$( "#send" ).click(function(e){
e.preventDefault();
$( "#send" ).prop( "disabled", true );
$( ".hideloader" ).show();
$( "#send" ).html( "Sending <img src='img/ajax-loader.gif'>" );
var form_data = $( "#contact-form" ).serialize();
$.ajax({
type: 'POST',
url: 'contact-submit.php',
data: form_data
}).done(function(response) {
$( "#server-results" ).hide().html(response).fadeIn("slow");
$( "#send" ).prop("disabled", false);
$( "#send" ).html( "Send Enquiry" );
$( "#contact-form" ).hide();
});
});
});
if ($_SERVER["REQUEST_METHOD"] === "POST") {
$message = "";
if(filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) === false) {
$message .= "Invalid email address. <br/>";
}
if($message) {
echo "<div class='red-error'><b>There were errors in your form:</b> <br/>" . $message . "</div>";
} else {
echo "<div class='green-success'>Thank you. We will respond to your enquiry as soon as possible.</div>";
}
}
ASKER
<form id="contact-form" method="post">
<div class="col-sm-6 col-xs-12">
<label class="contact">Email Address*</label>
<input type="email" name="email">
</div>
<div class="col-sm-6 col-xs-12">
<label class="contact">First Name*</label>
<input type="text" name="first_name">
</div>
<div class="col-sm-5 col-md-4 col-xs-6">
<button id="send" type="submit" name="submit" class="btn btn--primary type--uppercase">Send Enquiry</button>
</div>
</form>
<div id="server-results"></div>
PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.
TRUSTED BY