yii登陆中添加验证码
1、在SiteController中添加如下代码:
- /**
- * Declares class-based actions.
- */
- public function actions() {
- 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',
- ),
- );
- }
2、在 Model/LoginForm.php中
添加一个属性: public $verifyCode;
在rules数组最后添加:array('verifyCode', 'captcha', 'allowEmpty'=>!CCaptcha::checkRequirements()),
3、在视图中,在view/login.php中需要添加验证码的地方写上:
<input id='LoginForm_verifyCode' type="text" name="LoginForm[verifyCode]" >
<?php $this->widget('CCaptcha'); ?>
// 下面这个可以点击图片进行换验证码
<div><?php $this->widget('CCaptcha',array('showRefreshButton'=>false,'clickableImage'=>true,'imageOptions'=>array('alt'=>'点击换图','title'=>'点击换图','style'=>'cursor:pointer'))); ?></div>
yii登陆中添加验证码的更多相关文章
- Yii Model中添加默认搜索条件
在查询中增加条件 public function defaultScope() { return array( 'condition' => " is_deleted = 0" ...
- PHPCMS v9 自定义表单添加验证码验证
1. 在 \phpcms\templates\default\formguide\show.html 中添加验证码显示 <input type="text" id=" ...
- PHPCMS v9 自定义表单添加验证码
1. 在 \phpcms\templates\default\formguide\show.html 中添加验证码显示 <input type="text" id=&quo ...
- [phpcms v9]自定义表单添加验证码验证功能
修改 \phpcms\templates\default\formguide\show.html 中添加验证码显示 <input type="text" id=" ...
- 【转】PHPCMS v9 自定义表单添加验证码验证
1. 在 \phpcms\templates\default\formguide\show.html 中添加验证码显示 <input type="text" id=&quo ...
- .Net 登陆的时候添加验证码
一.ASPX 登陆界面验证码 1.登陆验证码图片和输入验证码框 <asp:TextBox ID="txtValiCode" runat="server" ...
- C# DateTime的11种构造函数 [Abp 源码分析]十五、自动审计记录 .Net 登陆的时候添加验证码 使用Topshelf开发Windows服务、记录日志 日常杂记——C#验证码 c#_生成图片式验证码 C# 利用SharpZipLib生成压缩包 Sql2012如何将远程服务器数据库及表、表结构、表数据导入本地数据库
C# DateTime的11种构造函数 别的也不多说没直接贴代码 using System; using System.Collections.Generic; using System.Glob ...
- Sqlserver 中添加数据库登陆账号并授予数据库所有者权限
Sqlserver 中添加数据库登陆账号并授予数据库所有者权限 USE master GO --通过sp_addlogin创建登录名 --DEMO:登陆账号 --123456:登陆密码 ' --切换数 ...
- yii添加验证码 和重复密码
<?phpnamespace frontend\models; use common\models\User;use yii\base\Model;use Yii; /** * Signup f ...
随机推荐
- 19异常和file部分笔记
19异常和file部分笔记-2018/09/041.异常 1.1 throwable()几个常见方法 * getMessage()获取异常信息,返回字符串 * toString()获取异常类名和异常 ...
- java mysql prepareStatement模糊查询like使用注意
今天在使用mysql 的like语句是,发现prepareStatement的like语句和一般的=写法有一样. 当要使用prepareStatement的like查询时,按照一般写法,都会写成: S ...
- Trees on the level (二叉链表树)
紫书:P150 uva122 Background Trees are fundamental in many branches of computer science. Current state- ...
- eclipse如何能快速找到某个文件夹或者文件
eclipse如何能快速找到某个文件夹或者文件 直接在editor中右键 Show in -> Package Explorer 在package explore 中选中link就可以了 (魔芋 ...
- JS动态添加div,然后在div中添加元素
需求: 组织部中有个这样的需求,根据年份动态显示该年份下的定性指标! 我的做法: 先是放一个空的div,让后根据指标的数据,动态的往div中添加元素. 代码: 空的div,存放定性指标 <div ...
- 特种部队(codevs 1427)
题目描述 Description 某特种部队接到一个任务,需要潜入一个仓库.该部队士兵分为两路,第一路士兵已经在正面牵制住了敌人,第二路士兵正在悄悄地从后方秘密潜入敌人的仓库.当他们到达仓库时候,发现 ...
- NOIP2005 树网的核
题目描述 Description [问题描述]设 T=(V, E, W) 是一个无圈且连通的无向图(也称为无根树),每条边带有正整数的权,我们称T 为树网(treenetwork),其中V, E分别表 ...
- android获取年月日时分秒
Calendar calendar=Calendar.getInstance(); //获取当前时间,作为图标的名字 String year=calendar.get(Calendar.YEAR)+& ...
- [poj2311]Cutting Game_博弈论
Cutting Game poj-2311 题目大意:题目链接 注释:略. 想法: 我们发现一次操作就是将这个ICG对应游戏图上的一枚棋子变成两枚. 又因为SG定理的存在,记忆化搜索即可. 最后,附上 ...
- redis sentinel集群配置及haproxy配置
ip分布情况: sentinel-1/redis 主 10.11.11.5 sentinel-2/redis 从 10.11.11.7 sentinel-3/redis 从 10.11.11.8 ha ...