BotDetect PHP CAPTCHA Integration Quickstart

1. Copy Captcha Library Files

Download the BotDetect PHP Captcha library, and copy the lib folder (contents simple-botdetect.php and the botdetect, config subfolders) to your website source.

2. Enable SQLite3

The SQLite3 extension is enabled by default as of PHP 5.3.0. Windows users must enable php_sqlite3.dll in order to use this extension.

BotDetect PHP Simple Captcha requires it to store Captcha codes, so you should ensure SQLite3 is enabled (or configure an alternative persistence mechanism).

3. Make Captcha configuration options

Update your Captcha configuration (config/botdetect.xml) file.
<?xml version="1.0" encoding="UTF-8"?>
<botdetect xmlns=""



4. 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 require("lib/simple-botdetect.php"); ?>
On the PHP form you want to protect against bots, add:
<?php // Adding BotDetect Captcha to the page
  $ExampleCaptcha = new SimpleCaptcha("ExampleCaptcha");
  echo $ExampleCaptcha->Html();

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

5. 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 = $ExampleCaptcha->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.2 CAPTCHA CakePHP 3 CAPTCHA CodeIgniter 3.0 CAPTCHA
Laravel 5.1 CAPTCHA CakePHP 2 CAPTCHA CodeIgniter 2.2 CAPTCHA
Laravel 5.0 CAPTCHA Symfony 3 CAPTCHA  
Laravel 4.2 CAPTCHA Symfony2 CAPTCHA  

Current BotDetect Versions