Captcha recaptcha不会验证

时间:2014-07-30 11:22:25

标签: php validation form-submit captcha recaptcha

我已经关注了Captcha的Google教程。

我添加了库。它显示在网站上,但是当我填写表格并离开时不要触摸它仍然发送的重新接收表格,而不是它的假设。

这是谷歌的主要代码:

<?php
require_once('recaptchalib.php');

// Get a key from https://www.google.com/recaptcha/admin/create
$publickey = "i have added the key here";
$privatekey = "i have added the key here";
# the response from reCAPTCHA
$resp = null;
# the error code from reCAPTCHA, if any
$error = null;

# was there a reCAPTCHA response?
if ($_POST["recaptcha_response_field"]) {
    $resp = recaptcha_check_answer ($privatekey,
                                    $_SERVER["REMOTE_ADDR"],
                                    $_POST["recaptcha_challenge_field"],
                                    $_POST["recaptcha_response_field"]);

    if ($resp->is_valid) {
            echo "You got it!";
    } else {
            # set the error code so that we can display it
            $error = $resp->error;
    }
}
 echo recaptcha_get_html($publickey, $error);
?>

我在想也许是在错误的地方。私钥是正确的。

该网站是:

http://www.the-big-bbq.co.uk/invitation.php#prettyPhoto

1 个答案:

答案 0 :(得分:0)

确保更新“recaptchalib.php”

中的键(以下变量)

define(“PUBKEY”,“”); define(“PRIKEY”,“”);