当提交的验证码不正确时,reCaptcha验证用户

时间:2012-10-16 21:03:26

标签: php codeigniter recaptcha

我正在尝试为我的Codeigniter项目设置reCaptcha。 recaptchalib.php文件保存在views文件夹中。

我的注册视图页面包含以下内容:

<form method="post" action="cyoa/verify.php">
<?php
require_once('recaptchalib.php');
$publickey = "correct_public_key_inserted_here";
echo recaptcha_get_html($publickey);
?>
<input type="submit" />
</form>

我的cyoa控制器包括以下验证功能:

public function verify()
{
    require_once('views/recaptchalib.php');
    $privatekey = "correct_private_key_inserted_here";
    $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
    die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
         "(reCAPTCHA said: " . $resp->error . ")");
    } else {
        redirect('cyoa/index');
    // Your code here to handle a successful verification
    }
}

我遇到的问题是页面总是重定向到cyoa / index。我做错了什么?

0 个答案:

没有答案