我正在尝试让reCaptcha在我的网站上使用表单,出于某种原因,我一直收到输入错误验证码的错误。有人看到我的代码有什么问题吗?
require_once('includes/recaptchalib.php');
$publickey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
$privatekey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
if (isset($category)) {
if ($edit == 'edit') {
include "includes/updatelisting.php";
} else {
$response = recaptcha_check_answer($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if ($response->is_valid) {
include "includes/insertlisting.php";
} else {
echo "Eh, That wasn't right. Try Again.";
}
}
} else {
以下是实际表格中的代码..
// Display the reCaptcha form
echo recaptcha_get_html($publickey, $error);
答案 0 :(得分:1)
我发现了这个问题。显然我的标签在标签内。一旦我将表格标签放在表格标签之外,一切都很完美。很奇怪。这是我找到Need help with reCAPTCHA - keep getting incorrect-captcha-sol
的答案的链接答案 1 :(得分:0)
当您致电echo recaptcha_get_html($publickey, $error);
时,您已经宣布了$error
吗?
您可能希望先声明它(是的,将其设为一个带有一个空格的字符串):
$error = ' ';
echo recaptcha_get_html($publickey, $error);
另外,在尝试验证之前,请检查是否确实设置了$category
。