【问题标题】:javascript prompt box for reCAPTCHAreCAPTCHA 的 javascript 提示框
【发布时间】:2012-05-07 17:14:45
【问题描述】:

我正在尝试制作一个自动提示框,显示错误 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();

        } 

【问题讨论】:

标签: php javascript prompt


【解决方案1】:

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

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

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

【讨论】:

    猜你喜欢
    • 2017-07-30
    • 2020-06-16
    • 2011-10-21
    • 2011-11-07
    • 1970-01-01
    • 2019-08-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多