cool-php-captcha下载地址:
cool-php-captcha具体效果:
cool-php-captcha代码实例:
session_start();
$captcha = new SimpleCaptcha();
// OPTIONAL Change configuration...
// $captcha->wordsFile = 'words/es.php';
// $captcha->session_var = 'secretword';
// $captcha->imageFormat = 'png';
// $captcha->scale = 3; $captcha->blur = true;
//$captcha->resourcesPath = "/var/cool-php-captcha/resources";
// OPTIONAL Simple autodetect language example
/*
if (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
$langs = array('en', 'es');
$lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
if (in_array($lang, $langs)) {
$captcha->wordsFile = "words/$lang.php";
}
}
*/
// Image generation
$captcha->CreateImage();
输出图片:
验证码校对:
if (empty($_SESSION['captcha']) || strtolower(trim($_REQUEST['captcha'])) != $_SESSION['captcha']) {
return "Invalid captcha";
}