Create a CAPTCHA Script with PHP

Tuesday Jan 5th 2010 by Octavia Anghel
Share:

Create your own simple CAPTCHA with PHP to protect your site from spammers and bots.

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:

  1. Generate random text.
  2. Generate the image containing the random text.

Read the entire article to learn how to create a CAPTCHA script with PHP.

Share:
Home
Mobile Site | Full Site
Copyright 2017 © QuinStreet Inc. All Rights Reserved