2

所以我试图让我的表格重新验证。这是我的表格代码。

<form action="" method="post">
 <input type="text" name="text4" id="text4" style="width:400px" /><br/><br/>' . '<script type="text/javascript"
   src="http://www.google.com/recaptcha/api/challenge?k=XXXXXXXXXXXXXXXXXX">
</script>
<noscript>
   <iframe src="http://www.google.com/recaptcha/api/noscript?k=XXXXXXXXXXXXXXXXXX"
       height="300" width="500" frameborder="0"></iframe><br>
   <textarea name="recaptcha_challenge_field" rows="3" cols="40">
   </textarea>
   <input type="hidden" name="recaptcha_response_field"
       value="manual_challenge">
</noscript><input type="button" value="Submit"/>

我正在尝试使用没有插件的recaptcha。让它显示很容易,但我很难验证输入。有人知道如何在没有插件的情况下进行验证吗?非常感谢。

4

1 回答 1

3

为了让 reCaptcha 正常工作,您的服务器端代码应该类似于此处发布的内容:

在任何服务器端语言中,如果不使用类似的解决方案,就无法让 reCaptcha 工作。这是代码:

require_once('recaptchalib.php');
$privatekey = "your_private_key";

$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 {
    // Your code here to handle a successful verification
}
于 2011-02-16T06:32:43.830 回答