BotDetect PHP CAPTCHA Integration Quickstart (BotDetect v3.0; deprecated)

1. Copy Captcha Library Files

Download the BotDetect PHP Captcha library, and copy the lib contents (botdetect.php and the botdetect subfolder) to your website source.

2. Show a Captcha Challenge on the Form

On the very top of the source file for the PHP form you want to protect against bots, add:
<?php session_start(); ?>
<?php require("botdetect.php"); ?>
On the PHP form you want to protect against bots, add:
  <link type="text/css" rel="Stylesheet" 
    href="<?php echo CaptchaUrls::LayoutStylesheetUrl() ?>" />


<?php // Adding BotDetect Captcha to the page 
  $SampleCaptcha = new Captcha("SampleCaptcha");
  $SampleCaptcha->UserInputID = "CaptchaCode";
  echo $SampleCaptcha->Html(); 

<input name="CaptchaCode" id="CaptchaCode" type="text" />

3. Check User Input During Form Submission

When the form is submitted, the Captcha validation result must be checked:
  if ($_POST) {
    // validate the Captcha to check we're not dealing with a bot
    $isHuman = $SampleCaptcha->Validate();
    if (!$isHuman) {
      // TODO: Captcha validation failed, show error message
    } else {
      // TODO: Captcha validation passed, perform protected action

In-Depth PHP CAPTCHA Instructions and Explanations

Detailed PHP Captcha instructions and explanations can be found in the PHP Captcha integration how to guide.

Other BotDetect PHP CAPTCHA Quickstarts

Laravel 5.1 CAPTCHA CakePHP 3.0 CAPTCHA CodeIgniter 3.0 CAPTCHA
Laravel 5.0 CAPTCHA CakePHP 2.6 CAPTCHA CodeIgniter 2.2 CAPTCHA
Laravel 4.2 CAPTCHA    

Please Note

The information on this page is out of date and applies to a deprecated version of BotDetect™ CAPTCHA (v3.0).

An up-to-date equivalent page for the latest BotDetect Captcha release (v4) is BotDetect v4 Captcha documentation index.

General information about the major improvements in the current BotDetect release can be found at the What's New in BotDetect v4.0 page.