所以我正在尝试使用我的表单进行验证码工作。这是我的表单代码。
<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。显示它很容易,但我很难验证输入。有人知道如何在没有插件的情况下进行验证吗? 非常感谢。
最佳答案
为了使 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
}
关于php - 在没有插件 reCAPTCHA 的情况下验证用户的答案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5012088/