我正在尝试创建一个自动提示框,显示错误的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();
}
答案 0 :(得分:0)
您可以使用GET参数重定向回登录页面,例如:login.php?captchaError=1
。然后在登录页面上添加:
<?php
if(isset($_GET['captchaError]))
{
echo("<script type='text/javascript'>
alert("Captcha entered incorrectly.");
</script>
");
}
?>
这将检查是否有错误并输出一些JS来显示警告。