| View previous topic :: View next topic |
| Author |
Message |
bobthebob1234 LXF regular

Joined: Thu Jan 03, 2008 9:38 pm Posts: 1360 Location: A hole in a field
|
Posted: Wed Jan 20, 2010 6:32 pm Post subject: reCAPTCHA |
|
|
I would like to add a captcha to a form I have (which sends emails...) However it works in IE (6) but not firefox (on ubuntu & winblows)...
here is some code
| Code: |
<form action="new.php" method="post" name="form">
<?php
require_once('recaptchalib.php');
$publickey = "(deleted)";
$privatekey = "(deleted) ";
# the response from reCAPTCHA
$resp = null;
# the error code from reCAPTCHA, if any
$error = null;
# are we submitting the page?
if ($_POST["submit"]) {
$error_count=0;
echo '
<tr>
<td colspan="2" class="errors">
Checking
</td>
';
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if ($resp->is_valid) {
echo "<tr><td colspan=\"2\" class=\"errors\">You got it!</td></tr>";
# in a real application, you should send an email, create an account, etc
} else {
# set the error code so that we can display it. You could also use
# die ("reCAPTCHA failed"), but using the error message is
# more user friendly
$error = $resp->error;
$error_count++;
echo '<tr><td colspan="2" class="errors">The captcha was incorrect. ' . $error . '</td></tr>';
}
if ($error_count > 0) {
$s ="";
if ($error_count > 1) {
$s = "s";
}
echo "<tr><td colspan=\"2\" class=\"errors\">There was $error_count error$s. Please correct these and try again.</td></tr>";
}
}
?>
|
and
| Code: |
<fieldset><legend>Captcha</legend>
Please enter the two words below.
<?php
echo recaptcha_get_html($publickey);
?>
</fieldset>
|
If i echo $_POST["recaptcha_challenge_field"], in firefox it is blank and in ie it has lots of random letters and hashs,etc
Any ideas why this would be, and how to fix it?
Thanks _________________ For certain you have to be lost to find the places that can't be found. Elseways, everyone would know where it was |
|
| Back to top |
|
 |
Dutch_Master LXF regular
Joined: Tue Mar 27, 2007 2:49 am Posts: 2359
|
Posted: Wed Jan 20, 2010 7:10 pm Post subject: |
|
|
phpBB3 has a working Cotcha environment, why not 'nick' their code?  |
|
| Back to top |
|
 |
ollie Moderator

Joined: Mon Jul 25, 2005 12:26 pm Posts: 2749 Location: Bathurst NSW Australia
|
Posted: Thu Jan 21, 2010 10:18 am Post subject: |
|
|
| Dutch_Master wrote: | phpBB3 has a working Cotcha environment, why not 'nick' their code?  |
reCAPTCHA supply the code required for free - no need to "nick" the code because it is free.
I haven't had any problems with reCATCHA, I've just included the code at http://recaptcha.net/plugins/php/. Point "3" goes at the top of your page. You make the page containing the form a PHP page and the code at point "4" goes on your form processing page (also PHP).
Note: I have deleted the public and private keys from your code posting, you don't want to give the private one out  |
|
| Back to top |
|
 |
bobthebob1234 LXF regular

Joined: Thu Jan 03, 2008 9:38 pm Posts: 1360 Location: A hole in a field
|
Posted: Thu Jan 21, 2010 6:22 pm Post subject: |
|
|
opps thanks.
I'll try coping and pasting that code (again...) (although i did use the example first...) _________________ For certain you have to be lost to find the places that can't be found. Elseways, everyone would know where it was |
|
| Back to top |
|
 |
Dutch_Master LXF regular
Joined: Tue Mar 27, 2007 2:49 am Posts: 2359
|
Posted: Thu Jan 21, 2010 6:26 pm Post subject: |
|
|
| ollie wrote: |
reCAPTCHA supply the code required for free - no need to "nick" the code because it is free. | Which is why I put it in ' marks  |
|
| Back to top |
|
 |
bobthebob1234 LXF regular

Joined: Thu Jan 03, 2008 9:38 pm Posts: 1360 Location: A hole in a field
|
Posted: Thu Jan 21, 2010 6:41 pm Post subject: |
|
|
Something else in the page must be breaking it. Have tried new code and still not work. However copied example code to new page it all is good.
I also regenerated the keys. _________________ For certain you have to be lost to find the places that can't be found. Elseways, everyone would know where it was |
|
| Back to top |
|
 |
bobthebob1234 LXF regular

Joined: Thu Jan 03, 2008 9:38 pm Posts: 1360 Location: A hole in a field
|
Posted: Thu Jan 21, 2010 7:05 pm Post subject: |
|
|
I think it doesn't like tables in tables. Got it to work now (for the moment!). Thanks to all. _________________ For certain you have to be lost to find the places that can't be found. Elseways, everyone would know where it was |
|
| Back to top |
|
 |
| View previous topic :: View next topic |
|