Problems with recaptcha. It always returns false

0

I have problems with the recaptcha and I can not see why it does not work. If you were able to help me I would appreciate it very much.

The problem is that I perform the recaptcha, it gives me that it is valid

and I fill in the form's data and send it to me, and this error comes up:

  

object (ReCaptchaResponse) # 2 (2) {["success"] = > bool (false)   ["errorCodes"] = > NULL} ERROR1

My file HTML

<head> <br>
   &nbsp;&nbsp;
   <script src='https://www.google.com/recaptcha/api.js?hl=es'></script> <br>
/head> <br><br>

form id="contacta" action="queryContact2.php" method="POST">
   <br>&nbsp;&nbsp;  ----- datos del formulario --------
   <br>&nbsp;&nbsp;  div class="control-group span4">
     <br>&nbsp;&nbsp;&nbsp;     div class="g-recaptcha" data-sitekey="clave"> /div>
    <br>/div>
   <br> button type="submit" id="send" class="btn btn-primary pull-right">Enviar <br> /button>
<br> /form>

My PHP file

?php <br>
  include('conexion.php');
  <br> $link = Conectarse(); 

    /*if(isset($_POST['inputName'])){*/
    require_once "recaptchalib.php";
    //include ('recaptchalib.php');
    $secret = "clave secreta";
    $response = null;
    $reCaptcha = new ReCaptcha($secret);
    $captcha = $_POST["g-recaptcha-response"];
    $ip = $_SERVER['REMOTE_ADDR'];


    if ($_POST["g-recaptcha-response"]) {
        $response = $reCaptcha->verifyResponse($ip, $captcha);
    }

    if(isset($_POST['inputPhone'])){
        var_dump($response);
           if ($response != null && $response->success) {

                 --------- si es true el valor del recaptcha entraría aquí ------------

           }else{
            echo "ERROR1";
            //header("Location: contacto2.html");
        }
    }else{
        echo "ERROR2";
        //header("Location: contacto2.html");
    }
?>

Thanks in advance

    
asked by wellsie 06.06.2018 в 16:54
source

0 answers