- add captcha.class.php to your system
- search any font in TTF or OTF, and set it in the Captcha class
- set captcha parameters as you wish, based on your site design
Quick example:
<?php
session_start();
include('captcha.class.php');
define(CAPTCHA_TTF, './myfont.ttf');
$captcha = new Captcha();
/* Optional: overwrite default parameters */
$captcha->str_length = 4;
if($_POST){
if($captcha->check($_POST['captcha_input'])){
/* success, do something */
} else {
/* error, do something */
}
}
?>
<form method="post">
<input type="text" name="name" />
<input type="text" name="email" />
<textarea name="message"></textarea>
...
<img src="<?php echo $captcha->get(); ?>" />
...
<input type="text" name="captcha_input" maxlength="4" />
</form>
PREFIX: If you use more captcha on one page, you can set prefix, e.g. contact, cart, etc.
Basic:
Shadows:
Push letters vertically up or down:
Rotate letters:
Draw random lines on the background:
And any sizes:
Patterns:
init
- some fixes
- simplification: remove captcha_image.php, the captcha image generated in the Captcha class
- use pattern
- replace the attributes of check() function
- quick fix at patterns
- error handling: if don't set font file print error message and exit
- remove reconfigure() function, because it's unnecessary
Note 1: session_start() required!
Note 2: minimum PHP version: 4.0.6
Font: https://fonts.google.com/specimen/Titillium+Web
Patterns: http://bgrepeat.com
All suggestions will be welcome. :)