关于TP框架中验证码的制作

来源:互联网 发布:中国汽车销售数据 编辑:程序博客网 时间:2024/05/20 18:01

对于我们常用的Thinkphp框架 我们通常采用在控制器处给予验证码的一个“方法”。并通过实例化,在html中实现功能。



html部分
<label class="col-sm-3 control-label" for="inputEmail">验证码:</label>

JS部分
<input type="text" name="verify"class="form-control verifyCheck" >
</div>
<div class="col-sm-6">
<span class="help-block"><img style="position: relative;top:-5px;left:-15px;border-radius: 3px;" height="35px" src="{:U('Public/verify')}" title="点击验证码刷新" onclick="this.src=this.src+'?t='+(new Date())" />
<span class="Validform_checktip"></span></span>
</div>
</div>

TP控制器Public.controller部分
public function verify(){
$config =array(
'fontSize' => 40, // 验证码字体大小
'length' => 4, // 验证码位数
'useNoise' => false, // 关闭验证码杂点
'bg' => array(219,241,252),
);
$Verify = new \Think\Verify( $config);
$Verify->entry();
}
原创粉丝点击