Answer the question
In order to leave comments, you need to log in
How to insert recaptcha correctly?
It's just that the form without recaptcha works, but I try to bind the recaptcha, it's just an empty answer and nothing comes to the mail. Where is the mistake?
<html>
<head>
<meta charset="utf-8" />
<title>HTML5</title>
<script src='https://www.google.com/recaptcha/api.js'></script>
</head>
<body>
</body>
</html>
<?php
$name = $_POST['name'];
$phone = $_POST['phone'];
$vopros = $_POST['vopros'];
$name = urldecode($name);
$phone = urldecode($phone);
$vopros = urldecode($vopros);
$name = urldecode($name);
$phone = urldecode($phone);
$vopros = urldecode($vopros);
$name = trim($name);
$phone = trim($phone);
$vopros = trim($vopros);
//echo $fio;
//echo "<br>";
//echo $email;
const GOOGLE_RECAPTCHA_PRIVATE_KEY = 'xxx';
if (isset($_POST['g-recaptcha-response'])) {
$params = [
'secret' => GOOGLE_RECAPTCHA_PRIVATE_KEY,
'response' => $_POST['g-recaptcha-response'],
'remoteip' => $_SERVER['REMOTE_ADDR']
];
$curl = curl_init('https://www.google.com/recaptcha/api/siteverify?' . http_build_query($params));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$response = json_decode(curl_exec($curl));
curl_close($curl);
if (isset($response->success) && $response->success == true) (mail("[email protected]", "Заявка с сайта","Комментарий: " .$vopros. "\n Имя: ".$name.". Номер: ".$phone ,"From: [email protected] \r\n")) {
echo "Вы прошли проверку reCaptcha";
} else {
echo "Вы не прошли проверку reCaptcha";
}
}
}?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question