欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

yii實(shí)現(xiàn)創(chuàng)建驗(yàn)證碼實(shí)例解析

 更新時間:2014年07月31日 16:53:52   投稿:shichen2014  
這篇文章主要介紹了yii實(shí)現(xiàn)創(chuàng)建驗(yàn)證碼的方法,很常見的一類功能,需要的朋友可以參考下

本文以實(shí)例形式講述了yii創(chuàng)建驗(yàn)證碼的方法,具體步驟如下所示:

一、在SiteController action()下添加如下代碼:

return array(
 // captcha action renders the CAPTCHA image displayed on the contact page
 'captcha'=>array(
 'class'=>'CCaptchaAction',
 'backColor'=>0xFFFFFF,
 ),
 // page action renders "static" pages stored under 'protected/views/site/pages'
 // They can be accessed via: index.php?r=site/page&view=FileName
 'page'=>array(
 'class'=>'CViewAction',
 ),
);

二、(1)在LoginForm model rules()下添加代碼:

//captche class needed
array('verifyCode', 'captcha','allowEmpty'=>!CCaptcha::checkRequirements()),

    (2)LoginForm model下添加屬性:

public $verifyCode;

三、在ContactForm model rules()下添加代碼:

// verifyCode needs to be entered correctly
array('verifyCode', 'captcha', 'allowEmpty'=>!CCaptcha::checkRequirements()),

四、在login view下添加代碼:

<div class="row">
<?php
echo $form->labelEx($model,'verifyCode');
?>
<?php
$this->widget('CCaptcha');
?>
<?php
echo $form->textField($model,'verifyCode');
?>
<?php
echo $form->error($model,'verifyCode');
?>
</div>

本例代碼僅為主要功能簡述,讀者還可以根據(jù)自身項(xiàng)目需求進(jìn)一步完善該程序代碼,使其功能更具實(shí)用性。

相關(guān)文章

最新評論