yii 验证码的使用
在HappyController 中加入
public function actions(){
return array(
// captcha action renders the CAPTCHA image displayed on the contact page
'captcha'=>array(
'class'=>'CCaptchaAction',
'backColor'=>0xFFFFFF, //背景颜色
'minLength'=>4, //最短为4位
'maxLength'=>4, //是长为4位
'transparent'=>true, //显示为透明
),
);
}
public function actionIndex(){
$this->layout = false;
$this->render('index');
}
在view视图中,添加如下代码,就可以得到验证码了。
<?php $this->widget('CCaptcha'); ?>
//课程验证码多余的get a new code ,即使在main.php中配置了中文也是出现获取新图片
<?php
$this->widget('CCaptcha',array('showRefreshButton'=>false,'clickableImage'=>true,'imageOptions'=>array('alt'=>'点击换图','title'=>'点击换图','style'=>'cursor:pointer'))); ?>


浙公网安备 33010602011771号