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.
Here is the generated 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,
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With