在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‘); ?>
yii 验证码的使用
时间: 2024-08-26 04:56:20