<form id="contact-form">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="name">
Name</label>
<input type="text" class="form-control" id="name" placeholder="Enter name" required="required" />
</div>
<div class="form-group">
<label for="email">
Email Address</label>
<div class="input-group">
<span class="input-group-addon"><span class="glyphicon glyphicon-envelope"></span>
</span>
<input type="email" class="form-control" id="email" placeholder="Enter email" required="required" /></div>
</div>
<div class="form-group">
<label for="subject">
Subject</label>
<select id="subject" name="subject" class="form-control" required="required">
<option value="na" selected="">Choose One:</option>
<option value="service">General Customer Service</option>
<option value="suggestions">Suggestions</option>
<option value="product">Product Support</option>
</select>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="name">
Message</label>
<textarea name="message" id="message" class="form-control" rows="9" cols="25" required="required"
placeholder="Message"></textarea>
</div>
</div>
<div class="col-md-12">
<button type="submit" class="btn btn-skin pull-right" id="btnContactUs">
Send Message</button>
</div>
</div>
</form>
<form id="contact-form" action="/email.php" metod="post">
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="/js/script.js"></script>
$(document).ready(function(){
$('#contact-form').submit(function(){
var subject = $(this).find("#subject :selected").text();
var name = $(this).find("#name").val();
var email = $(this).find("#email").val();
var message = $(this).find("#message").val();
if(!!name && !!email && !!message){
$.ajax({
type: "POST",
url: "/email.php",
data: {"subject": subject, "name": name,"email": email, "message": message},
cache: false,
success: function(){
/* действия при успешной отправке */
}
})
}
return false;
});
});
<? header("Content-type: text/html; charset=utf-8");
$text = "<b>subject</b>: ".$_POST['subject']."<br>";
$text .= "<b>name</b>: ".$_POST['name']."<br>" ;
$text .= "<b>email</b>: ".$_POST['email']."<br>";
$text .= "<b>message</b>: ".$_POST['message']."<br>";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=UTF-8\r\n";
mail('mail@mail.ru', 'Заголовок письма', $text, $headers);
?>