添加带验证码的登陆:

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,
                        ),
                }

Yii添加验证码的更多相关文章

  1. yii添加验证码 和重复密码

    <?phpnamespace frontend\models; use common\models\User;use yii\base\Model;use Yii; /** * Signup f ...

  2. yii登陆中添加验证码

    1.在SiteController中添加如下代码: /** * Declares class-based actions. */ public function actions() { return  ...

  3. asp.net添加验证码

    1.新建一个aspx页面生成验证码图像 using System; using System.Data; using System.Configuration; using System.Collec ...

  4. PHPCMS v9 自定义表单添加验证码验证

    1. 在 \phpcms\templates\default\formguide\show.html 中添加验证码显示 <input type="text" id=" ...

  5. Angular企业级开发(9)-前后端分离之后添加验证码

    1.背景介绍 团队开发的项目,前端基于Bootstrap+AngularJS,后端Spring MVC以RESTful接口给前端调用.开发和部署都是前后端分离.项目简单部署图如下,因为后台同时采用微服 ...

  6. PHPCMS v9 自定义表单添加验证码

    1.  在 \phpcms\templates\default\formguide\show.html 中添加验证码显示 <input type="text" id=&quo ...

  7. cas4.2.4 登添加验证码

    看了很多添加验证码的博文,唯独没有4.24的 重点看第3条,其余的和别人博文大致相同 1.首先在cas工程的web.xml增加验证码功能的支持 <!-- 验证码功能 -->      &l ...

  8. [phpcms v9]自定义表单添加验证码验证功能

    修改  \phpcms\templates\default\formguide\show.html 中添加验证码显示 <input type="text" id=" ...

  9. 【转】PHPCMS v9 自定义表单添加验证码验证

    1.  在 \phpcms\templates\default\formguide\show.html 中添加验证码显示 <input type="text" id=&quo ...

随机推荐

  1. iOS float小数四舍五入

    http://blog.csdn.net/fanjunxi1990/article/details/21536189 直接贴代码了 #import "ViewController.h&quo ...

  2. Google Breakpad 之一,跨平台crash 处理上报系统简介

    Google Breakpad 之一,跨平台crash 处理上报系统简介 http://blog.csdn.net/wpc320/article/details/8290501 Google Brea ...

  3. 最小生成树Prim算法Kruskal算法

    Prim算法采用与Dijkstra.Bellamn-Ford算法一样的“蓝白点”思想:白点代表已经进入最小生成树的点,蓝点代表未进入最小生成树的点. 算法分析 & 思想讲解: Prim算法每次 ...

  4. Stack的三种含义 ----超级经典 明白了 栈 的三种含义

    来自:http://www.ruanyifeng.com/blog/2013/11/stack.html ----------------------------------------------- ...

  5. KVM(八)使用 libvirt 迁移 QEMU/KVM 虚机和 Nova 虚机

    1. QEMU/KVM 迁移的概念 迁移(migration)包括系统整体的迁移和某个工作负载的迁移.系统整理迁移,是将系统上所有软件包括操作系统完全复制到另一个物理机硬件机器上.虚拟化环境中的迁移, ...

  6. hdu 5174(计数)

    Ferries Wheel Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Tot ...

  7. springBoot Feign Hystrix Dashboard

    1.引入依赖 <!-- 引入关于 hystrix Dashboard的依赖 --> <dependency> <groupId>org.springframewor ...

  8. thinkphp实现功能:验证码

    1.定义验证码函数 public function verify(){ /** * 在thinkPHP中如何实现验证码 * * ThinkPHP已经为我们提供了图像处理的类库ThinkPHP\Exte ...

  9. (转)zeromq 安装

    http://youzifei.iteye.com/blog/1698237 zeromq 今天在安装zeromq的时候费了好大的力气才算装好 下面来回顾一下在linux安装zeromq的过程 首先 ...

  10. HBASE启动失败,Failed construction of Master: class org.apache.hadoop.hbase.master.HMaster

    Master日志错误:2015-12-02 06:34:32,394 ERROR [main] master.HMasterCommandLine: Master exitingjava.lang.R ...