Home arrow PHP arrow Page 3 - Improve PHP Captcha with Optical Character Recognition Tests

Increasing captcha difficulty - PHP

If you're working on a captcha system for your PHP-based website, you may be faced with an interesting challenge. How do you make your system too hard for spam bots to read, but not too hard for humans? This is especially worrying in the wake of bots that can harness OCR for reading captchas. This article explains how to increase the difficulty of a captcha system and test it to make sure it meets your requirements.

  1. Improve PHP Captcha with Optical Character Recognition Tests
  2. Adding background noise to captcha
  3. Increasing captcha difficulty
  4. The final script
By: Codex-M
Rating: starstarstarstarstar / 4
August 02, 2010

print this article



To make the captcha five times as difficult, you will need to set the value of $c < 40  to around $c < 40*5 or $c < 200 so the FOR loop condition will now look like this:

for ($c = 0; $c < 200; $c++){


   $x = rand(0,50-1);


   $y = rand(0,50-1);


   imagesetpixel($imagecreate, $x, $y, $textcolor);



To see how the captcha looks at this setting, go to this link: http://www.php-developer.org/antibot.php

Below is the evaluation result of this captcha against strong OCR:


Ten samples were evaluated, and there wasn't a single accurate detection by the OCR.

This means the increasing the background noise to five times the original level increases the difficulty of the captcha level to the point that it could not be  accurately detected by the optical character recognition engine.

>>> More PHP Articles          >>> More By Codex-M

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates


Dev Shed Tutorial Topics: