A Simple PHP CAPTCHA Script

This is one of the easiest CAPTCHA scripts you will ever use. While it doesn't obscure the text, it will serve its purpose well for many people who need a low-level CAPTCHA solution. This script requires little-to-no setup. The only dependency is the PHP GD library.

Example CAPTCHA image:

Captcha example

It can be as simple as this to use, but it is also configurable:

$_SESSION['captcha'] = captcha();
echo '<img src="' . $_SESSION['captcha']['image_src'] . '" alt="CAPTCHA" />';


  • Use one or more PNG backgrounds
  • Use one or more TTF or OTF fonts
  • Set minimum/maximum code lengths (or optionally set the code itself)
  • Configure which characters to use
  • Set minimum/maximum font size
  • Adjustable angle, font color, and shadow
  • Includes the free font "Times New Yorker" (for demo purposes) and a sample background image (default.png)

Demo & Download

This project is actively maintained on GitHub.  Please submit all issues and contributions to the project page.  Licensed under both the MIT and the GNU GPL licenses.

Demo Page | Download the latest version from GitHub

Author avatar

About the author

Creator of Surreal CMS and other web things. Follow me for tweets about JavaScript, CSS, and web programming.