PHP头条
热点:

PHP验证码工具-Securimage


最近项目中接触到了一个新的php验证码工具 -Securimage,使用起来非常简单和方便,并且支持ajax调用,因此在这里给大家推荐一下。

什么是Securimage?

Securimage是一个开源/免费的phpCAPTCHA脚本,它可以用来生成复杂的验证码图片,帮助您的网站防止spam。它可以轻松嵌入网站已存的表单中,为您的网站提供spam机器人的防护。它可以运行于大部分支持php(GD)的webserver上。

*点击这里查看快速指南
*Securimage实例
*下载最新版本

Securimage的特性:

* 仅用三行代码即可显示验证码
* 仅用六行代码即可对验证码的输入进行验证
* 自定义验证码长度
* 自定义字符集
* 支持TTF
* 使用自定义的GD字体(若TTF不支持)
* 轻松添加自定义背景图片
* 丰富的文本支持,包括颜色/角度/透明度选项
* 文字淆乱Arched lines through text
* 生成wav格式的CAPTCHA音频文件
* 自定义CAPTCHA的验证码列表

下面给大家一个简单的例子:

<html>
<head>
  <title>Securimage Test Form</title>
</head>
<body>
<?php
if (empty($_POST)){?>
<form method="POST">
Username:<br />
<input type="text" name="username" /><br />
Password:<br />
<input type="text" name="password" /><br />
 
<!-- 调用securimage,显示验证码图片,sid是用来防止被cache住的 -->
<img src="securimage_show.php?sid=<?php echomd5(uniqid(time()));?>"><br />
<input type="text" name="code" /><br />
<input type="submit" value="Submit Form" />
</form>
 
<?php
} else{//form is posted
 include("securimage.php");
 $img=new Securimage();
 $valid=$img->check($_POST[code]);//检查用户的输入是否正确
 
 if($valid==true) {
   echo "<center>Thanks, you entered the correct code.</center>";
 } else{
   echo "<center>Sorry, the code you entered was invalid.  <a href="javascript:history.go(-1)">Go back</a> to try again.</center>";
 }
}
 
?>
 
</body>
</html>
securimage_show.php的代码:

<?php
include securimage.php;//下载包里面的核心类库代码
$img=new securimage();
$img->show();// alternate use:  $img->show(/path/to/background.jpg);
?>

www.phpzy.comtrue/phprm/28308.htmlTechArticlePHP验证码工具-Securimage 最近项目中接触到了一个新的php验证码工具 -Securimage,使用起来非常简单和方便,并且支持ajax调用,因此在这里给大家推荐一下。 什么是Securimage? Securimage是...

相关文章

    暂无相关文章

PHP之友评论

今天推荐