A dead simple PHP captcha.
This captcha should be considered as a proof of concept, and a simple demo of image generation in PHP.
It should not be used on production environments, as it can be easily defeated by captcha solvers or OCR softwares.
- Enable PHP GD
- Get
captcha.php
Call the script in a <img>
tag in a form:
<img src="/path/to/captcha.php?rand=<?php echo md5(microtime(true)); ?>">
The image goes with an <input>
:
<input type="text" name="captcha_value">
On form submit, check the entered value:
if (!empty($_SESSION['simple_captcha']) && !empty($_POST['captcha_value']) && $_SESSION['simple_captcha'] == $_POST['captcha_value'])
{
// The captcha is valid
}
Version | Date | Notes |
---|---|---|
1.0.0 |
August 29, 2015 | Initial version |
This project is released under the MIT License.