Created
February 19, 2017 20:40
-
-
Save webbash/f0c263dd031843b90379e8cb1c71f3e5 to your computer and use it in GitHub Desktop.
This file contains 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 | |
$secret = "SECRET KEY FROM GOOGLE"; | |
$ip = $_SERVER['REMOTE_ADDR']; | |
$captcha = $_POST['g-recaptcha-response']; | |
$rsp = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=$secret&response=$captcha&remoteip$ip"); | |
$arr = json_decode($rsp, TRUE); | |
if ($arr['success']) { | |
$name = htmlspecialchars($_POST['']); | |
$email = htmlspecialchars($_POST['']); | |
$telephone = htmlspecialchars($_POST['']); | |
$comment = htmlspecialchars($_POST['']); | |
$headers = "MIME-Version: 1.0\r\n"; | |
$headers .= "Content-type: text/html;charset=utf-8 \r\n"; | |
$message = " | |
<p><strong>Имя:</strong> $name</p> | |
<p><strong>Email:</strong> $email</p> | |
<p><strong>Телефон:</strong> $telephone</p> | |
<p><strong>Имя мастера:</strong> $username</p> | |
<p><strong>Комментарий:</strong> $comment</p>"; | |
if (mail("ADRESS MAIL", "Обратный звонок", | |
$message, $headers)) { | |
echo "1"; | |
} else { | |
echo "0"; | |
} | |
} else { | |
echo '0'; | |
} | |
// Ajax | |
.done(function() { | |
if (response == 1) { | |
alert('Успешно отправлено'); | |
} else { | |
alert('Проверьте данные'); | |
}); | |
.fail(function() { | |
if(response == 0) { | |
alert('Ошибка сервера почты'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment