- Community Pick
- Experts Exchange Approved
If you're like me and don't have tons of time to discover and implement new things/features on your website then you'll like this quick and easy example to keep automated bots from exploiting your web application forms. In just a couple of steps I'll walk you through on how to get the Captcha tool on your website.
The beauty of Captcha is that it is free and requires virtually zero of your server space. Installation is as easy as a couple lines of code in your form's page and adding the captcha library php file to your directory. Then one simple if - then statement determines what the application should do depending on whether the user entered an appropriate captcha or not.
To get started head on over to http://www.google.com/reca
If you have successfully signed up and have the recaptchalib.php file and a private and public key you're ready to finish up.
First of all let's start with a simple php page (form.php) with a form that submits the inputted text on another page (success.php) if the captcha entry was valid; if not, then we show an error message below the captcha on the form page.
This example asks the user to input his favorite food and insert the Captcha. If the Captcha is correct, the user will be directed to a success page that shows his entry - otherwise an error message is displayed telling the user that the Captcha was entered incorrectly.
form.php
success.php
For this to work you need recaptchalib.php, form.php, and success.php to be in the same directory and your respective private and public keys set.
That's it, you can see how easy it is to determine what your web application will do when the captcha is correct or not. There are more customization options available if you check out http://code.google.com/api
If you want to see a working example of the example you can check it out here: http://www.patsmitty.com/c
Also the source files are attached.
Cheers
by: dspector on 2010-09-08 at 11:44:36ID: 19195
Image-based CAPTCHAs keep blind and visually impaired people out of your website or resource. Period. They are not fair, and someday will be illegal (since they violate the civil rights of an identified group of people).
Unless you are Yahoo! or similar, you won't have enough traffic to justify the use of an Image-based CAPTCHA, even ignoring the fairness angle. Why not use a text-based CAPTCHA? It is just as easy to add to your website, loads faster, doesn't discriminate against older folks who don't see so well, and lets people in quicker while baffling the limited logical capabilities of spammer's software.
I own a number of websites that use text-based CAPTCHA to submit Contact Us forms. I never have a problem with spam. Never. And my CAPTCHA is so simple: just copy three random digits into a text field. It can even be done by copy and paste. And if a spammer breaks it, all I have to do is change it a little. Add a digit, move the location of the field, almost any change keeps spammers out.
So simple, so fair.
David Spector