duanju8308 2015-04-13 00:54
浏览 131

Google No captcha Recaptcha无效

Hope someone could help..i have got the widget to show for the no captcha recaptcha and i have found a code on the internet that i am trying to use because i am not that good with php but it seems to work only partially. everytime that i click the box or that i dont and i try to send an email it says please check the captcha.

this is what i have in my mail confirm.php file which is the server side (i dont think theres a need to post the widget code as it shows and works, which is step 1)

$email;$message;$sujet;$header;$captcha;
    if(isset($_POST['email'])){
      $email=$_POST['email'];
    }if(isset($_POST['message'])){
      $email=$_POST['message'];

}if(isset($_POST['sujet'])){
      $email=$_POST['sujet'];
}if(isset($_POST['header'])){
      $email=$_POST['header'];


    }if(isset($_POST['g-recaptcha-response'])){
      $captcha=$_POST['g-recaptcha-response'];
    }
    if(!$captcha){
      echo '<h2>Please check the the captcha form.</h2>';
      exit;
    }
        $response=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=6LcIAgETAAAAAEjbARzUsrkgBIHAeE8QmsNE3US-&response=".$captcha."&remoteip=".$_SERVER['REMOTE_ADDR']);
    if($response.success==false)
    {
      echo '<h2>You are spammer ! Get the @$%K out</h2>';
    }
    else
    {
      echo '<h2>Thanks for posting comment.</h2>';
    }
  • 写回答

1条回答 默认 最新

  • dongpangzan6425 2015-04-14 00:48
    关注

    Modify this code to your desires.

    <?
        $APIkey = "API KEY";
        $postresult=$_POST['g-recaptcha-response'];
        $response=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=$APIkey&response=$postresult");
    
        if (strpos($response, 'true')){
            //Captcha is valid, do whatever.
        } else {
            //Captcha is invalid. Tell them to go away.
        }
    
    ?>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 BP神经网络控制倒立摆
  • ¥20 要这个数学建模编程的代码 并且能完整允许出来结果 完整的过程和数据的结果
  • ¥15 html5+css和javascript有人可以帮吗?图片要怎么插入代码里面啊
  • ¥30 Unity接入微信SDK 无法开启摄像头
  • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算