CAPTCHA is a very simple and common protection that helps prevent spam and the automatic submission of an operation by some kind of program or robot. CAPTCHA protection is used on web site forms and works by generating a random string, writing it to an image, then storing the string inside of a session. Then, the site checks the CAPTCHA when the form is submitted. In her PHPBuilder.com article, Octavia Andreea Anghel provides step-by-step instructions for making your own simple CAPTCHA image using PHP.
The core of the demo application is a PHP class capable of generating random text and an image that will contain the text (the class is encapsulated in the GeneratedCaptcha.php script). This image will be your CAPTCHA. At a high level, to create your CAPTCHA image you take the following steps:
- Generate random text.
- Generate the image containing the random text.
Read the entire article to learn how to create a CAPTCHA script with PHP.