BotDetect CAPTCHA Crash Course

On this page we demonstrate how easy is to integrate BotDetect Captcha in your forms.

We'll use default BotDetect settings; to see how powerful and customizable BotDetect is, check the BotDetect features demo.

1. Copy Captcha Library Files

Copy BotDetect.php and the BotDetect folder to your application. These files (and a sample project made by following these instructions, named "Basic CAPTCHA sample") are included in the BotDetect installation.

2. Show a Captcha Challenge on the Form

On the very top of the PHP form you want to protect against bots, add:

<?php session_start(); ?>

On the PHP form you want to protect against bots, add:

  <?php require("BotDetect.php"); ?>
</head>

  […]

<?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:

<?php 
  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
    } 
  }
?>

BotDetect CAPTCHA Options

To find more about configuring BotDetect and integrating it in various usage scenarios, please check the getting started with BotDetect Captcha page.

Please Note

BotDetect 3.0 PHP Captcha Library Alpha is a work in progress, and we need you to guide our efforts towards a polished product. Please let us know if you encounter any bugs, implementation issues, or a usage scenario you would like to discuss.

The PHP library does not yet support the full feature set of the other BotDetect 3.0 Captcha products (ASP.NET and ASP Classic). Captcha localization and Captcha sounds are not implemented yet, but are coming soon.