2014-02-19 140 views
0

我有一个Google recapture拒绝接受我的答案(错误:不正确的captcha-sol)但我想我已经测试了每一步没有任何问题。它在一个简单的HTML/CSS类型的网站上。Google Recaptcha incorrect-captcha-sol

  • 我可以在Firebug中看到响应和挑战是从联系表单发送的。
  • 我已经在php中回显字段,他们是我发送的相同(匹配萤火虫)
  • 我在同一页上有一张表,但它不是(或与任何方式有关)联系表格。

HTML代码:

<!-- Contact Form --> 
     <div class="row"> 
      <div class="span9"> 
       <form id="contact-form" class="contact-form" action="#"> 

        <p class="contact-name"> 
         <input id="contact_name" type="text" placeholder="Full Name (Required)" value="" name="name" /> 
        </p> 
        <p class="contact-email"> 
         <input id="contact_email" type="text" placeholder="Email Address (Required)" value="" name="email" /> 
        </p> 
        <p class="contact-message"> 
         <textarea id="contact_message" placeholder="Your Message (Required)" name="message" rows="15" cols="40" maxlength="150"></textarea> 
        </p> 
        <p class="contact-challenge"> 
         <div id="recaptcha_widget" style="display:none"> 
          <div id="recaptcha_image"></div> 
          <div class="recaptcha_only_if_incorrect_sol" style="color:red">Incorrect please try again</div> 

          <span class="recaptcha_only_if_image">Enter the words above:</span> 
          <span class="recaptcha_only_if_audio">Enter the numbers you hear:</span> 

          <input id="recaptcha_response_field" type="text" name="recaptcha_response_field" /> 

          <div><a href="javascript:Recaptcha.reload()">Get another CAPTCHA</a></div> 
          <div class="recaptcha_only_if_image"><a href="javascript:Recaptcha.switch_type('audio')">Get an audio CAPTCHA</a></div> 
          <div class="recaptcha_only_if_audio"><a href="javascript:Recaptcha.switch_type('image')">Get an image CAPTCHA</a></div> 

          <div><a href="javascript:Recaptcha.showhelp()">Help</a></div> 
         </div> 
        </p> 

        <script type="text/javascript" src="http://www.google.com/recaptcha/api/challenge?k=XXXX"> 
        </script> 
        <noscript> 
         <iframe src="http://www.google.com/recaptcha/api/challenge?k=XXXX" height="300" width="500" frameborder="0"></iframe> 
         <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea> 
         <input type="hidden" name="recaptcha_response_field" value="manual_challenge"> 
        </noscript> 
        <p class="contact-submit"> 
         <a id="contact-submit" class="submit" href="#">Send</a> 
        </p> 
        <div id="response"> 
        </div> 
       </form> 

      </div> 

PHP

require_once('recaptchalib.php'); 
$privatekey = "XXXX"; 
$resp = recaptcha_check_answer ($privatekey, 
           $_SERVER["REMOTE_ADDR"], 
           $details["recaptcha_challenge_field"], 
           $details["recaptcha_response_field"]); 
    if (!$resp->is_valid) { 
    // What happens when the CAPTCHA was entered incorrectly 

    $this->response_html .= '<p>The code you entered was incorrect, please try again. ' . $resp->error . '</p>'; 
    $this->response_status = 0;  
    } 

感谢

回答

1

我终于想通了我没有初始化$ RESP之前,我用它。 所以我现在已经有了

$resp = null; 

IF语句开始前和现在的代码工作正常。

这就是我得到的复制/粘贴Google的代码,而不是仔细检查它!