CAPTCHA Example

Usage

The following code will prepare a CAPTCHA image and keep the code in a session variable for later use:

After the call to simple_php_captcha() above, $_SESSION['captcha'] will be something like this:

Array ( [code] => yYY [image_src] => /mdrone/simple-php-captcha/simple-php-captcha.php?_CAPTCHA&t=0.11183400+1745955650 )
yYY

To display the CAPTCHA image, create an HTML <img> using $_SESSION['captcha']['image_src'] as the src attribute:

CAPTCHA code

To verify the CAPTCHA value on the next page load (or in an AJAX request), test against $_SESSION['captcha']['code']. You can use strtolower() or strtoupper() to perform a case-insensitive match.

Configuration

Configuration is easy and all values are optional. To specify one or more options, do this:

Notes