recaptcha总是不正确的php和boostrap

recaptcha总是不正确的php和boostrap,php,twitter-bootstrap,captcha,recaptcha,Php,Twitter Bootstrap,Captcha,Recaptcha,我正在为我的网站制作一个登录页面。我使用标准的recaptcha来验证新帐户,但我的recaptcha总是以不正确的方式返回。我已经尝试了stackoverflow上列出的所有标准修复程序。我使用bootstrap 3.x时代码中没有表,我今天从google服务器中提取了recaptcha.php文件,它有API的新位置。我不知道它为什么这样做。我已经检查过了,并且再次检查了我的代码,但不包括公共代码和私人代码 任何帮助都会很好。下面是两段代码。首先,在我的index.php页面上:

我正在为我的网站制作一个登录页面。我使用标准的recaptcha来验证新帐户,但我的recaptcha总是以不正确的方式返回。我已经尝试了stackoverflow上列出的所有标准修复程序。我使用bootstrap 3.x时代码中没有表,我今天从google服务器中提取了recaptcha.php文件,它有API的新位置。我不知道它为什么这样做。我已经检查过了,并且再次检查了我的代码,但不包括公共代码和私人代码

任何帮助都会很好。下面是两段代码。首先,在我的index.php页面上:

            Register:
        <form class="navbar-form navbar-left" role="search" action="php/verify.php" >

            <div class="input-group">
                <span class="input-group-addon">Username</span>
                <input type="text" name="username" class="form-control" placeholder="Username" >
            </div>

            <div class="input-group">
                <span class="input-group-addon">Email</span>
                <input type="text" name="email" class="form-control" placeholder="Email">
            </div>

            <div class="input-group">
                <span class="input-group-addon">Password</span>
                <input type="password" name="password" class="form-control" placeholder="Password">
            </div>

            <?php
              require_once('php/recaptchalib.php');
              $publickey = "xxxxxxxxxxxxxxxx-changed for security"; // you got this from the signup page
              echo recaptcha_get_html($publickey);
            ?>

            <button type="submit" value="Register" class="btn btn-default">Submit</button>
        </form>
然后,下面是verify.php文件:

  require_once('recaptchalib.php');
  $privatekey = "xxxxxxxxxxxxxx-changed for safety";
  $resp = recaptcha_check_answer ($privatekey,
                                $_SERVER["REMOTE_ADDR"],
                                $_POST["recaptcha_challenge_field"],
                                $_POST["recaptcha_response_field"]);

  if (!$resp->is_valid) {
    // What happens when the CAPTCHA was entered incorrectly
            $message = "Your CAPTCHA was wrong, please retry.";
            echo "<script type='text/javascript'>
                    alert('$message');
                    window.location = '../';
                  </script>";

  } 
  else {
            $message2 = "Your CAPTCHA was right!!";
            echo "<script type='text/javascript'>
                    alert('$message2');
                    window.location = '../';
                  </script>";
  }

警报“$message”-真的吗?你怎么能用警告信息亵渎一个看起来可能不错的引导网站?你试过调试POST值以查看你收到了什么吗?我之所以使用alert是因为我不知道如何在同一页面上显示它是不正确的,所以它是一个空白填充器。我刚开始使用PHP,但我还不擅长:我只是将它与我上一个正在工作的reCaptcha实现进行了对比,它几乎相同,但只是警报部分。你有没有想过,你可能只是没有通过验证码?你试过多少次了?我们可以用链接试一试吗?我是说。。。这些CAPTCHA有时比您预期的更难阅读。此外,在这样一个简单的代码实现中,代码出错的可能性较小。您是在本地环境还是在生产环境中进行测试?我正在进行在线直播-这就是证明