reCaptcha值未出现在$ _POST中 [英] reCaptcha values not appearing in $_POST
问题描述
我正在尝试在我的网站上使用reCaptcha,并且recaptcha_challenge_field和recaptcha_response_field并未添加到后端的$ _POST数组中-但我表单中的其余变量都已添加.
I am trying to use reCaptcha on my site, and recaptcha_challenge_field, and recaptcha_response_field are not being added to the $_POST array on the backend - but the rest of the variables from my form are.
有什么想法吗?我已经仔细检查了公钥/私钥.
Any ideas? I have double checked the public/private keys.
这是生成的HTML:
<form action='myform.php' name='myform' id='myform' method='post' enctype='multipart/form-data'>
<tr class='select'>
<td class='label'>Name:</td>
<td>
<input type='text' name='name' id='name' class='inputtext' maxlength='25' size='25' >
</td>
</tr>
<tr class='select'>
<td class='label'>Email:</td>
<td>
<input type='text' name='email' id='email' class='inputtext' maxlength='25' size='25' >
</td>
</tr>
<tr class='select'>
<td class='label'>Message:</td>
<td>
<textarea class='inputtext' name='message' rows='10' cols='45'></textarea>
</td>
</tr>
<tr class='select'>
<td class='label'>Are you human?</td>
<td>
<script type="text/javascript" src="http://api.recaptcha.net/challenge?k=MY_KEY"></script>
<noscript>
<iframe src="http://api.recaptcha.net/noscript?k=MY_KEY" 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>
</td>
</tr>
<tr>
<td>
</td>
<td style='text-align: left;' colspan='2'>
<input type='submit' class='button' value='Send message'>
</td>
</tr>
</form>
到目前为止,这是我的管理员:
Here is my handler so far:
print_r($_POST);
require_once('inc/recaptchalib.php');
$privatekey = "MY_PRIVATE_KEY";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
print_r($resp);
if (!$resp->is_valid) {
die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
"(reCAPTCHA said: " . $resp->error . ")");
}
任何帮助将不胜感激.谢谢
Any help would be really appreciated. Thank you,
推荐答案
可以想象,由于交错< table>
和< form>的方式,您可能会遇到DOM问题.;
.尝试将< form>
和</form>
标记移到< table>
和</table>之外.
.
Conceivably you might be having DOM problems because of the way you're interleaving <table>
and <form>
. Try moving your <form>
and </form>
tags outside your <table>
and </table>
respectively.
这篇关于reCaptcha值未出现在$ _POST中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!