• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 257
  • Last Modified:

Implementing Recaptcha on a Form

A form on my website has recently been inundated with SPAM bots that are resulting in a lot of SPAM entries in the database. I would like to implement recaptcha on the form. I went to the Google Recaptcha site, entered the domain name and obtained the public and private keys and uploaded the recaptcalib.php to the relevant directory. I placed the code relating to the public key before the "Submit" button in the form, but am not quite sure where to put the code relating to the private key, i.e.,

require_once(dirname(__FILE__) . "/../recaptchalib.php");
        $privatekey = "Privatekeydigits...";
        $resp = recaptcha_check_answer ($privatekey,
                                $_SERVER["REMOTE_ADDR"],
                                $_POST["recaptcha_challenge_field"],
                                $_POST["recaptcha_response_field"]);
        
        if (!$resp->is_valid) {
          // What happens when the CAPTCHA was entered incorrectly
          die("The reCAPTCHA numbers/letters did not match the image. Please click your browser's back button and try it again.");

I believe it has to go where the onsubmit() function in the form is but am not quite sure where to put it.

I would appreciate any help on this.
Brochure-Request.html
0
geeta_m9
Asked:
geeta_m9
  • 2
2 Solutions
 
Dave BaldwinFixer of ProblemsCommented:
The part starting with require_once(dirname(__FILE__) . "/../recaptchalib.php"); goes on the PHP page that the form POSTs to, your 'action' page.  However, I don't think your 'servlet.webtolead ' page will support the PHP code.  Here's some code for JAVA: https://developers.google.com/recaptcha/docs/java
0
 
Ray PaseurCommented:
If you can access and modify the PHP files that create and process your scripts, there are many different ways of implementing a CAPTCHA test without using ReCaptcha, which has been broken repeatedly by several attackers.  This article shows some of the ways that may not yet be subject to successful attacks.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_9849-Making-CAPTCHA-Friendlier-with-PHP-Image-Manipulation.html

If you do not know where to put the code after you have read the article, please be respectful of your time and consider hiring a professional developer to help with the work.  It will not cost very much and it will save you a great deal of time!
0
 
geeta_m9Author Commented:
Thank you for your suggestion, Ray. Can you suggest a site or sites where I may be able to find someone to hire to help me fix this problem?

Thanks.
0
 
Ray PaseurCommented:
Sure - this one!  Many of the E-E community have "hire me" buttons on their profiles.  Here's a link to my profile.
http://www.experts-exchange.com/members/Ray_Paseur.html
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now