Captchas

About CAPTCHAs

CAPTCHAs are used to prevent spam robots from filling out forms and submitting junk information to a website. They generally work by requiring the submitter to perform some task that is simple for a human but difficult for a computer algorithm.

How do they work? Generally, a CAPTCHA system requires that you add some stuff like Javascript code to your website. You usually just download the code from someone who created the CAPTCHA. Then you include in your form an image created by the code. The image contains something like some distorted looking numbers and letters that humans can read. You place a text field next to the image and request the user to type in what s/he sees in the image.

When the user presses the submit button, the PHP page that process the algorithm sends the user's response to the Javascript code which indicates whether or not the user's response was correct.

$_POST array


Not checking a CAPTCHA

Examples

Secureimage

A very simple to implement system, with customizable images. See the Quick Start guide for details.

  1. Download the secureimage directory from the Secureimage.zip file.
  2. Upload the secureimage directory to your host (<root>\secureimage).
  3. Include the following elements in your file (e.g. <root>\myform.php). See it work...
  4. <?php
    /* Put this at the VERY TOP of your PHP form */
    session_start();
    ?>

    <html>
    <head>
    <title>WEB Place Secureimage CAPTCHA demo</title>
    </head>

    <body>

    <?php
    include_once $_SERVER['DOCUMENT_ROOT'] . '/securimage/securimage.php';

    $securimage = new Securimage();

    if ($securimage->check($_POST['captcha_code']) == false)
    {
      echo "Incorrect";
    }
    else
    {
      echo "Correct";
    }
    ?>

    <!-- This is the form -->
    <form method="post" action="secureimage_demo.php">
    <img id="captcha" src="/securimage/securimage_show.php" alt="CAPTCHA Image" />
    <input type="text" name="captcha_code" size="10" maxlength="6" />
    <a href="#" onclick="document.getElementById('captcha').src = '/securimage/securimage_show.php?' + Math.random(); return false">Reload Image</a>
    <input type="submit" value="Submit">
    </form>

    </body>
    </html>
Free Web Hosting