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,
        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.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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:

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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.

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!
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?

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.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.