PHP Classes

SGCaptcha: CAPTCHA validation using geometric shapes

Recommend this page to a friend!
  Info   View files Example   Screenshots Screenshots   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 371 All time: 6,786 This week: 160Up
Version License PHP version Categories
sgcaptcha 1MIT/X Consortium ...5.0PHP 5, Graphics, Validation, Security


This class implements CAPTCHA validation using geometric shapes.

It can generate an image with several geometric shapes and associated numbers on them.

The user is required to enter the numbers that are in images of one of the types of geometric shape displayed in the end of the CAPTCHA image.

The correct answer is stored in session variable for subsequent verification.

Innovation Award
PHP Programming Innovation award nominee
July 2014
Number 3

Prize: One downloadable copy of PhpED Professional
CAPTCHA solutions are useful to prevent that sites are abused by robot scripts.

However, some CAPTCHA solutions become a little to hard to authenticate real users.

This class implements an approach that provides a simple solution by letting the users pick numbers associated with given geometric shapes displayed around the numbers.

Manuel Lemos
Picture of Francisco del Aguila
  Performance   Level  
Name: Francisco del Aguila <contact>
Classes: 2 packages by
Country: Spain Spain
Age: 58
All time rank: 167842 in Spain Spain
Week rank: 362 Up11 in Spain Spain Up
Innovation award
Innovation award
Nominee: 2x

Winner: 1x


// Example for the PHP simple geometric captcha
$sent = (isset($_SESSION['captcha'])) ? TRUE : FALSE;
    if (
$sent) {
$value = stripslashes(strip_tags(trim($_POST['value'])));
$captchaOk = ($value == $_SESSION['captcha']) ? TRUE : FALSE;
<!DOCTYPE html>
    <meta charset="UTF-8" />
    <meta name="application-name" content="Simple geometric captcha for PHP" />
    <meta name="author" content="Francisco del Aguila." />
    <title>Simple geometric captcha example</title>
if ($sent) {
            if (
$captchaOk) {
            } else {
<h1>Simple geometric captcha example</h1>
    <img src="sgcaptcha.php" style="width:350px;" alt="Captcha" />
    Input the digits inside the key figures.
    (Key figures are the ones equal to the black coloured, at the right)
    <form action="example.php" method="post">
        <input type="text" name="value" size="12" maxlength="12" />
        <input type="submit" value="submit" />
    <span style="font-size:.8em;">
        Copyright &copy; 2014, Francisco del Aguila<br/>
        This software is under the MIT license.<br/>
        See contents of file README.txt for more information.


Simple geometric captcha for PHP -------------------------------- Version 1. 2014-06-07. Author: Francisco del Aguila (, Generate a captcha with geometric figures. USAGE Include the next line in your HTML/PHP webpage: <img src="{path}/sgcaptcha.php" alt="Captcha" /> The captcha solution value is stored in $_SESSION['captcha'] The key figure appears at right with no value. User must input digits inside the key figures. The result may be an empty string. See the 'example.php' file. You can change the colour schema and length of the key editing the file 'captcha.php'. REQUIREMENTS Requires GD library enabled in PHP. LICENSE This software is published under the MIT license. (see This information must remain in all copies of this software. HISTORY Version 1, 2014-06-07. First version.

  • Image1.jpg
  Files folder image Files  
File Role Description
Accessible without login Plain text file example.php Example Sample use of sgcaptcha.php
Accessible without login Plain text file LICENSE.txt Lic. License
Accessible without login Plain text file README.txt Doc. Basic information
Plain text file sgcaptcha.php Class The sgcaptcha class

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:6,786
This week:160Up