zoukankan      html  css  js  c++  java
  • Yii添加验证码

    添加带验证码的登陆:

    1.先在模型modules下的LoginForm.php定义一个存储验证码的变量:public $verfyCode;


    2.然后在rules()方法里定义:array('verifyCode', 'captcha', 'allowEmpty'=>!CCaptcha::checkRequirements());

    3.然后在对应视图views下的login.php里定义:
        <?php if(CCaptcha::checkRequirements()): ?>
            <div class="row">
                    <?php echo $form->labelEx($model,'verifyCode'); ?>
                    <div>
                    <?php $this->widget('CCaptcha'); ?>
                    <?php echo $form->textField($model,'verifyCode'); ?>
                    </div>
                    <div class="hint">Please enter the letters as they are shown in the image above.
                    <br/>Letters are not case-sensitive.</div>
                    <?php echo $form->error($model,'verifyCode'); ?>
            </div>
        <?php endif; ?>
    4.在login所属的的控制器中加入:
    public function actions()
            {
                    return array(
                            // captcha action renders the CAPTCHA image displayed on the contact page
                            'captcha'=>array(
                                    'class'=>'CCaptchaAction',
                                    'backColor'=>0xFFFFFF,
                            ),
                    }
  • 相关阅读:
    iOS controller 和 window 图层
    iOS CGAffineTransform 仿射变换
    iOS UIButton的UIEdgeInsets
    iOS UI的动态布局
    iOS 栅格动态布局
    iOS 系统键盘几个类型
    iOS 金融类高精度处理
    Sublime Text (崇高文本)
    iOS 静态库——制作bundle
    iOS 静态库——制作Framework
  • 原文地址:https://www.cnblogs.com/grimm/p/5414739.html
Copyright © 2011-2022 走看看