I want to send form on email and I don't understand why this code not work.
giving 200 OK
On other site email can be sent
php echo
and echo json_encode()
not show in response.
EMail correct.
NOTE: A message stating that this question has a lot of code, and more information should write just got. I'm sorry, I'm here copypaste text.
HTML
<form role="form" id="contactform" method="POST">
<div class="form-group">
<input type="text" class="form-control" id="name" placeholder="Ваше имя" name="name">
</div>
<div class="form-group">
<input type="text" class="form-control" id="phone" placeholder="Контактный номер телефона" name="phone">
</div>
<div class="form-group">
<input type="text" class="form-control" id="city" placeholder="Город" name="city">
</div>
<div class="form-group">
<textarea class="form-control" rows="4" placeholder="Количество панелей и Ваше сообщение" id="message" name="message"></textarea>
</div>
<button type="submit" id="contact_submit" data-loading-text="•••" class="btn btn-lg btn-block btn-primary"><i class="icon icon-paper-plane"></i>Заказать</button>
</form>
JS
$(document).ready(function(){
$("#contactform").submit(function() {
$.ajax({
type: "POST",
url: "/contact.php",
data: $("#contactform").serialize(),
success: function() {
$('#contact_submit').button('reset');
$('#modalContact').modal('hide');
//Use modal popups to display messages
$('#modalMessage .modal-title').html('<i class="icon icon-envelope-open"></i>Ваше сообщение успешно отправлено!<br>Наш менеджер перезвонит Вам в ближайшее время.<br>Благодарим за заявку!');
$('#modalMessage').modal('show');
},
error: function() {
$('#contact_submit').button('reset');
$('#modalContact').modal('hide');
//Use modal popups to display messages
$('#modalMessage .modal-title').html('<i class="icon icon-ban"></i>Oops!<br>Something went wrong!');
$('#modalMessage').modal('show');
}
})
return false;
});
});
CONTACT PHP
<?php
$recepient = "**************";
$sitename = "**************";
$subject = "New message from \"$sitename\"";
$name = trim($_POST["name"]);
$phone = trim($_POST["phone"]);
$city = trim($_POST["city"]);
$message1 = trim($_POST["message"]);
$message = "
Name: $name <br>
phone: $phone <br>
city: $city <br>
message: $message1
";
mail($recepient, $subject, $message, "From: pinta-acoustic.ru");
?>