验证码"incorrect-captcha-sol"



实际密钥已编辑"我正在使用 ReCaptcha 实现一个简单的登录表单。验证码给了我这个错误:"未正确输入 reCAPTCHA。回去再试一次。(reCAPTCHA 说:不正确的验证码-sol)">这是我的代码:

索引.php

<table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<form name="form1" method="post" action="verify.php">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td colspan="3"><strong>Member Login </strong></td>
</tr>
<tr>
<td width="78">Username</td>
<td width="6">:</td>
<td width="294"><input name="myusername" type="text" id="myusername" /></td>
</tr>
<tr>
<td>Password</td>
<td>:</td>
<td><input name="mypassword" type="text" id="mypassword" /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><input type="submit" name="Submit" value="Login" /></td>
</tr>
</table>
</td>
</form>
</tr>
</table>
<html>
<title>Title Dolan Webiste</title>
<body>
<script type="text/javascript" src="http://www.google.com/recaptcha/api/challenge?k=actual_key_redacted"></script>
<noscript>
<iframe src="http://www.google.com/recaptcha/api/noscript?k=actual_key_redacted" 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>
</body>
</html>

验证.php

<?php
echo "<pre> _POST: =========n";
print_r($_POST);
echo "n=========n</pre>";
require_once('recaptchalib.php');
$privatekey = "private_key_here";
$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有 recaptchalib。

看到这个...

$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]

$_POST变量数组来自提交时的form数据。 问题是,当您未能将这些字段放入form容器中时,表单数据发布数组如何包含recaptcha_challenge_fieldrecaptcha_response_field

您必须将 reCaptcha 小部件放在form容器,或放在<form></form>标签之间

<form name="form1" method="post" action="verify.php">
.... the rest of your form here
<script type="text/javascript"
src="http://www.google.com/recaptcha/api/challenge?k=actual_key_redacted">
</script>
<noscript>
<iframe src="http://www.google.com/recaptcha/api/noscript?k=actual_key_redacted"
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>
</form>

但是,不确定为什么您在执行print_r($_POST);时没有注意到丢失的帖子数据

相关内容

最新更新