//生成验证码public function verify(){
$config = array (
'fontSize' => 16,
'length' => 4,
'useNoise' => False,
);
$Verify = new \Think\Verify( $config );
$Verify ->entry();
}
|
//验证函数 function check_verify( $code , $id = '' ){
$verify = new \Think\Verify();
return $verify ->check( $code , $id );
}
|
//模板输出 < img src = "{:U('Support/verify')}" style = "cursor:pointer;" onClick = "this.src=this.src+'?'+Math.random()" id = "verify" /> < span class = "next" onClick = "document.getElementById('verify').src='{:U('Support/verify')}?+Math().random()';" style = "cursor:pointer;" >看不清,< a >换一张</ a ></ span >
|
//控制器验证 if (!check_verify(I( 'code' ))){
$this ->error( '验证码错误' );
} else {
}
|