您的位置:首页 > 其它

验证码

2016-04-12 20:26 274 查看
//验证码生成方法

public function img(){

$config = array(

'imageW'=>150,

'imageH'=>40,

'fontSize'=>18, // 验证码字体大小
'length'=>4,// 验证码位数
'useNoise'=>true, // 关闭验证码杂点

);

$Verify = new\Think\Verify($config);

$Verify->entry(1);

}

//静态页面调用验证码生成方法

<<span style="color:#e3e3ff;font-weight:bold;">p>

<<span style="color:#e3e3ff;font-weight:bold;">label>验证码</<span style="color:#e3e3ff;font-weight:bold;">label>

<<span style="color:#e3e3ff;font-weight:bold;">input class="text-input" type="text" name="code" />

</<span style="color:#e3e3ff;font-weight:bold;">p>

<<span style="color:#e3e3ff;font-weight:bold;">div class="clear"></<span style="color:#e3e3ff;font-weight:bold;">div>

<<span style="color:#e3e3ff;font-weight:bold;">p>

<<span style="color:#e3e3ff;font-weight:bold;">img src="<{:U('Login/img')}>" onclick="JavaScript: this.src+=('?'+Math.random());">

</<span style="color:#e3e3ff;font-weight:bold;">p>

//验证码验证

$code=$_POST['code'];

$Verify = new\Think\Verify();

$re=$Verify->check($code, $id=1);

if(!$re){

$this->error('验证码错误','index',1);

}else{

$this->success('验证码正确','Index/index',1);

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: