reCAPTCHA PHP to stop spam

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Sebarry
    New Member
    • Jul 2007
    • 69

    reCAPTCHA PHP to stop spam

    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
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    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?

    Comment

    • Sebarry
      New Member
      • Jul 2007
      • 69

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

      At the top of the PHP file:

      Code:
      require_once('includes/recaptcha-php-1.9/recaptchalib.php');
      
      $privatekey = "6LeYowAAAAAAAMiylx8fE5Hs85ZfX7KraUler1gi";
      $publickey = "6LeYowAAAAAAAFLqbuAe3Byvu98D0EQAZuyvSVH2"; // you got this from the signup page
      $smarty->assign( 'recaptcha', recaptcha_get_html( $publickey ) );
      To process the form:

      Code:
      $resp = recaptcha_check_answer ($privatekey,
          $_SERVER["REMOTE_ADDR"],
          $_POST["recaptcha_challenge_field"],
          $_POST["recaptcha_response_field"]);
      Sean

      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?

      Comment

      Working...