Last active
January 31, 2019 16:34
-
-
Save Padilo300/167978015bdf3b798b0b7c9c467783d8 to your computer and use it in GitHub Desktop.
Оправляем mail ajax
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if((isset($_POST['name'])&&$_POST['name']!="")){ | |
$to = '[email protected]' ; | |
$subject = 'Отзыв на вакансию' ; | |
$name = trim(urldecode(htmlspecialchars($_POST['name']))) ; | |
$email = trim(urldecode(htmlspecialchars($_POST['email']))) ; | |
$section = trim(urldecode(htmlspecialchars($_POST['postiton']))) ; | |
if(isset($_POST['phone'])){ | |
$name = trim(urldecode(htmlspecialchars($_POST['name']))); | |
}else{ | |
$subject = 'Подписка на вакансии'; | |
} | |
if(isset($_POST['phone'])){ | |
$phone = trim(urldecode(htmlspecialchars($_POST['phone']))); | |
}else{ | |
$phone = "Не указан" ; | |
} | |
$message=' | |
<html> | |
<head> | |
<title>'.$subject.'</title> | |
</head> | |
<body> | |
<p>Имя: '.$name.'</p> | |
<p>email: '.$email.'</p> | |
<p>Телефон: '.$phone.'</p> | |
<p>Вакансия: '.$section.'</p> | |
</body> | |
</html>'; | |
$headers = "Content-type: text/html; charset=utf-8 \r\n"; | |
$headers .= "From: [email protected]\r\n"; | |
if (mail($to, $subject, $message, $headers)){ | |
return true; | |
} else { | |
return $message ; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form action="/php/sendMail.php" method="POST" id="SendMail" > | |
<h3 class="mainTittle--center "> | |
напиши нам | |
</h3> | |
<div class="formInner"> | |
<input type="text" placeholder="Имя"> | |
<input type="number" placeholder="Телефон"> | |
<input type="mail" placeholder="Электронная почта"> | |
<input type="text" placeholder="Организация"> | |
</div> | |
<button class="btnTheme1--xs" type="submit"> | |
Отправить | |
</button> | |
</form> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$("#SendMail").submit(function() { | |
var form_data = $(this).serializeArray(); | |
$.ajax({ | |
type: "POST", | |
url: "/php/sendMail.php", | |
data: form_data, | |
success: function () { | |
$('#modalFuncYou').modal('show'); | |
$('#SendMail').trigger('reset'); | |
}, | |
error: function (data) { | |
console.log(data); | |
} | |
}); | |
return false; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment