2

我正在尝试制作一个显示错误 reCAPTCHA 输入错误的自动提示框,目前我有一个函数'redirect_to',它链接到一个相同的页面,我打算只以文本形式输入一个错误。如果有人可以帮助我,我将不胜感激,我对javascript没有太多经验。

 require_once($_SERVER['DOCUMENT_ROOT'] . '/recaptcha/recaptchalib.php');
        $privatekey ="*********";
        $resp = recaptcha_check_answer ($privatekey,
                            $_SERVER['REMOTE_ADDR'],
                            $_POST['recaptcha_challenge_field'],
                            $_POST['recaptcha_response_field']);
        $str_result = "";
        if (!$resp->is_valid) {

            redirect_to("login_recap.php");

             // What happens when the CAPTCHA was entered incorrectly
            $message = "The reCAPTCHA wasn't entered correctly. Go back and try it again. (reCAPTCHA   said: " . $resp->error . ")";
            echo $message;
            exit();

        } 
4

1 回答 1

0

您可以使用 GET 参数重定向回登录页面,例如:login.php?captchaError=1. 然后在您的登录页面上,只需添加:

<?php
if(isset($_GET['captchaError]))
{
echo("<script type='text/javascript'>
alert("Captcha entered incorrectly.");
</script>
");
}
?>

这将检查是否有错误并输出一些 JS 来显示警报。

于 2012-11-19T19:41:16.310 回答