Connecting Tech Pros Worldwide Forums | Help | Site Map

reCAPTCHA PHP to stop spam

Member
 
Join Date: Jul 2007
Posts: 69
#1: Nov 12 '07
Hi,

Has anyone used this successfully in PHP to prevent spam mails sent from HTML forms? I've added it to a form of mine and it seems a bit hit and miss. I incorrectly enter the captcha and it correctly says its incorrect. I try again with another incorrect response and it accepts it?

Am I doing something wrong or is there a problem with reCAPTCHA?

Thanks,

Sean

Atli's Avatar
Moderator
 
Join Date: Nov 2006
Location: Iceland
Posts: 3,754
#2: Nov 12 '07

re: reCAPTCHA PHP to stop spam


Hi Sean.

There must something be a little of for it to act like that. It could simply be that you overlooked some minor detail when you wrote your code.

Did you write the code from scratch or are you using something you got from somewhere else?
Could you show us the code that is likely to be causing this behavior?
Member
 
Join Date: Jul 2007
Posts: 69
#3: Nov 12 '07

re: reCAPTCHA PHP to stop spam


Hi Thanks, yes my code is as follows. I'm using Smarty with PHP.

At the top of the PHP file:

Expand|Select|Wrap|Line Numbers
  1. require_once('includes/recaptcha-php-1.9/recaptchalib.php');
  2.  
  3. $privatekey = "6LeYowAAAAAAAMiylx8fE5Hs85ZfX7KraUler1gi";
  4. $publickey = "6LeYowAAAAAAAFLqbuAe3Byvu98D0EQAZuyvSVH2"; // you got this from the signup page
  5. $smarty->assign( 'recaptcha', recaptcha_get_html( $publickey ) );
  6.  
To process the form:

Expand|Select|Wrap|Line Numbers
  1. $resp = recaptcha_check_answer ($privatekey,
  2.     $_SERVER["REMOTE_ADDR"],
  3.     $_POST["recaptcha_challenge_field"],
  4.     $_POST["recaptcha_response_field"]);
  5.  
Sean

Quote:

Originally Posted by Atli

Hi Sean.

There must something be a little of for it to act like that. It could simply be that you overlooked some minor detail when you wrote your code.

Did you write the code from scratch or are you using something you got from somewhere else?
Could you show us the code that is likely to be causing this behavior?

Reply