p. I hate bots on the net. (Except when I’m using them to “drive traffic to my blog”:http://ars.userfriendly.org/cartoons/?id=20060321.) But as a web programmer they are a pain in my Ethernet port if you catch my drift. So how do you keep them out but let people in? You use those little boxes of random letters and numbers that you can read and decipher but (currently) computers can’t.
p. The technical term for these images is “Captcha”:http://en.wikipedia.org/wiki/Captcha. They are used to protect your site by showing something that a computer can’t recognize but a human can. (most of the time) They are usually placed on your registration page but they can be placed anywhere you want to make reasonably sure you are dealing with a person and not a bot. To use them, you simply place the image somewhere on your page, ask the user what they see and then validate the results. The concept is simple but how do you implement it without sitting at Photoshop all night creating thousands of images? Well, the boys and girls over at “CodeFX.com”:http://www.codedfx.com have put together a little “tutorial”:http://www.codedfx.com/index.php?id=tutorialfull&did=42 to show you how they did it.
p. Most of you will like this, it’s a lot of code and just a few lines about what it does. (If you are in management, you might want to grab a programmer before visiting the page.) The code looks reasonably complete and a quick reading shows that it should do the job. This isn’t the most complex captcha I’ve seen written in PHP. It is however, a simple one that you can use if you want to dive in and figure out what is going on. The code is clean and simple so you can easily grasp and extend it.
p. Reading it over, they don’t mention it directly, but it is implied that you need your copy of PHP compiled with the gd libraries. Also, you will need a TrueType font file. Most machines have some lying around somewhere but if you draw a blank, here’s a hint: “Ask Google”:http://www.google.com/search?q=true+type+fonts and you shall receive.