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:

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

Features:

  • 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

Cory LaViska is a founder, web developer, and bootstrapper based in Orlando, Florida. Need to get in touch? Follow @claviska on Twitter!