标签:
<?php
namespace Admin\Controller;
use Think\Controller;
use Think\Verify;
class LoginController extends Controller{
public function Login(){
if(!empty($_POST)){
$vry = new Verfiy();
if($vry->check($_POST[‘capchat‘])){
echo “验证码正确”;
}
}
}
public function verfiyImage(){
//验证码配置
$config = array(
‘imageH‘ => 45, //验证码的图片高度
‘imageW‘ =>100, //验证码的图片宽度
‘fontSize‘ => 15, //验证码的字体大小
‘length‘ =>4, //验证码的长度
‘fontttf‘ => ‘2.ttf‘, //验证码的字体
}
//实例化verify类
$very = new Verfiy($config);
//输出验证码
$very -> entry();//输出验证码
}
在login.html页面中
<img src="{$smarty.const.__CONTROLLER__}/VerfiyImage" onclick= "this.src=‘{$smarty.const.__CONTROLLER__}/VerfiyImage/‘+Math.rondom()">
标签:
原文地址:http://www.cnblogs.com/chenchenphp/p/5271754.html