Javascript “重述”;不正确的验证码sol“;
“我用REcaptcha实现了一个简单的登录表单。 REcaptcha向我提供了以下错误: “没有正确输入reCAPTCHA。返回并重试。(reCAPTCHA说:验证码不正确) 这是我的代码: Index.phpJavascript “重述”;不正确的验证码sol“;,javascript,php,recaptcha,Javascript,Php,Recaptcha,“我用REcaptcha实现了一个简单的登录表单。 REcaptcha向我提供了以下错误: “没有正确输入reCAPTCHA。返回并重试。(reCAPTCHA说:验证码不正确) 这是我的代码: Index.php <table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <form name="form1" meth
<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> </td>
<td> </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>
会员登录
用户名
:
密码
:
标题:Dolan Webiste
Verify.php
<?php
echo "<pre> _POST: =========\n";
print_r($_POST);
echo "\n=========\n</pre>";
?>
<?php
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
}
?>
看这个
<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>
$\u POST
变量数组来自提交时的表单
数据。问题是,表单数据POST数组如何包含recaptcha\u challenge\u字段
和recaptcha\u response\u字段
,如果您未能将这些字段放入表单
容器中
必须将reCaptcha小部件放在表单
容器内,或者放在
和
标记之间
……剩下的表格在这里
但是,我不知道为什么在打印时没有注意到缺少的post数据;
您显示您在HTML中输入了公钥,但您并没有表示您在PHP中输入了私钥。是吗?是的,我更改了它,试图隐藏我的私钥(它可能被滥用或其他)我100%确信我输入了正确的代码,我复制粘贴了它。如果你不知道代码的作用,或者不知道出错时如何调试,就不要复制/粘贴代码。@PeteR说了什么。如果你缺乏基本知识,比如重新验证码小部件需要如何放在表单
容器中,你就不能盲目复制/粘贴代码。这仍然有效还是无效我会使用?@IronFist,AFAIK发布的示例,这个答案没有错,它适用于您链接的同一版本。如果您有相反的信息,请分享。我的错,我没有意识到您的答案是针对禁用的JS用户的。它没有错。@IronFist,它适用于两者,因此使用脚本在noscript
标记上方的ode>标记。
<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>