K
K
kachi882019-01-30 13:50:10
PHP
kachi88, 2019-01-30 13:50:10

Why is the recaptcha v3 processing form not working?

Such a question, why doesn’t this back on php simply display anything, even the registered messages are sent or not, and the letter is not sent.

<?php
//Выполняем проверку после отправки формы
if(isset($_POST['g-recaptcha-response'])) {
    $secretKey = '<6LdM2I0UAAAAAJ7FZp5hwY_MHXTTZg1kTT_3wKWr>';
    $response = $_POST['g-recaptcha-response'];     
    $remoteIp = $_SERVER['REMOTE_ADDR'];
 
 
    $reCaptchaValidationUrl = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=$secretKey&response=$response&remoteip=$remoteIp");
    $result = json_decode($reCaptchaValidationUrl, TRUE);
 
    //выводим полученный ответ от сервера
    print_r($result);
 
    if($result['success'] == 1) {
        $name = $_POST['name'];
        $phone = $_POST['phone'];
        $vopros = $_POST['vopros'];
        $email = $_POST['email'];
        $usluga = $_POST['usluga'];
        $name = urldecode($name);
        $phone = urldecode($phone);
        $vopros = urldecode($vopros);
        $email = urldecode($email);
        $name = urldecode($name);
        $phone = urldecode($phone);
        $vopros = urldecode($vopros);
        $email = urldecode($email);
        $name = trim($name);
        $phone = trim($phone);
        $vopros = trim($vopros);
        $email = trim($email);
    
        if (mail("[email protected]", "С сайта site.ru - заявка по экологической безопасности","Комментарий: " .$vopros. " \n  Email: " .$email."\n  Имя: ".$name."\n  Номер: ".$phone ,"From: [email protected] \r\n"))
         {     echo "Сообщение успешно отправлено!";
        }
      
    } else {
       
        echo "Не отправлено";
    }
}
?>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Gamov, 2019-01-31
@slowdream

isset($_POST['g-recaptcha-response'])
Does it actually return true?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question