Yes you read it right…! 5 lines of code
I know its hard to believe but this has to be one of the simplest implementation of Captcha, mainly because i can’t find any easier ones.
So here goes, this is how it works:
At the top of the page with the form you want to Captcha protect add these 3 lines of code, this generates the Captcha and adds it all to a nice variable to print out later:
$captcha = new Captcha;
$captchaImage = $captcha->create();
Then in your form where you want the Captcha, usually at the bottom, just above the submit button add this line, enclosed in php tags of course, this adds the captcha elements to the form:
So that is the form part done, now we just need to verify what the user has put in. For this i am going to assume that you are verifying atleast one part of the users input, so we need to add this line into it:
This would probably fit into your current checking like so:
Of course we have to add these 2 lines at the top of this processing page aswell (these are not included in the ‘5′ because they have already been added.
$captcha = new Captcha;
And thats it, the class handles everything else, well you have to put the files on your web-server, create a new directory to store the images and make it writeable, but thats a one-shot 10 second job!
Now for a screenshot:

Now for demo and the code:
AutoCompleter Tutorial
As always, links to a demo and ZIP at the bottom, Enjoy!
I thought i would write this tutorial because most of the auto completer applications i have seen just dump the code into a zip and tell you how to use it rather than how and why it works, knowing about this enables you to customise it a lot more (this has been demonstrated with the other apps i have written here)!
Can you imagine working for a company that has a little more than 500 employees and has the following statistics:
- 29 have been accused of spousal abuse
- 7 have been arrested for fraud
- 19 have been accused of writing bad checks
- 117 have directly or indirectly bankrupted at least 2 businesses
- 3 have done time for assault
- 71 cannot get a credit card due to bad credit
- 14 have been arrested on drug-related charges
- 8 have been arrested for shoplifting
- 21 are currently defendants in lawsuits
- 84 have been arrested for drunk driving in the last year
Can you guess which organization this is?
Give up yet?
It’s the 535 members of the United States Congress. The same group that cranks out hundreds of new laws each year designed to keep the rest of us in line.
Ha, they must be the happiest couple in the world!