1,在home模块indexController.class.php中,加入以下代码

<?php
namespace Home\Controller;
use Think\Controller;
class BookController extends Controller { public function verify_c(){
$Verify = new \Think\Verify();
$Verify->fontSize = 18;
$Verify->length = 4;
$Verify->useNoise = false;
$Verify->codeSet = '0123456789';
$Verify->imageW = 130;
$Verify->imageH = 50;
//$Verify->expire = 600;
$Verify->entry();
} public function img(){
$this->display();
} }

2. 在img 视图中,加入以下代码

<script type="text/javascript" src="__PUBLIC__/js/jquery2.0.3.min.js"></script>
<p class="top15 captcha" id="captcha-container">
<input name="verify" width="50%" height="50" class="captcha-text" placeholder="验证码" type="text">
<img width="100" class="left15" height="50" alt="验证码" src="{:U('Home/Book/verify_c',array())}" title="点击刷新">
</p>
<script type="text/javascript">
$(function(){
var captcha_img = $('#captcha-container').find('img');
var verifyimg = captcha_img.attr("src");
captcha_img.attr('title', '点击刷新');
captcha_img.click(function(){
if( verifyimg.indexOf('?')>0){
$(this).attr("src", verifyimg+'&random='+Math.random());
}else{
$(this).attr("src", verifyimg.replace(/\?.*$/,'')+'?'+Math.random());
}
});
})
</script>

这样就可以了,就能显示出 验证码了。

参考学习 网址:http://blog.csdn.net/yafei450225664/article/details/40424025

Thinkphp 3.2 添加 验证码 如何添加。的更多相关文章

  1. 【SSO单点系列】(3):CAS4.0 登录页验证码的添加

    2016.08.23 更新 注意:这个教程只适合4.0版本的,4.1以及以上的版本的已经不试用了, 后面几篇有人提到过 源码网盘链接更新了下 : 链接: http://pan.baidu.com/s/ ...

  2. asp.net添加验证码

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

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

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

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

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

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

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

  6. cas4.2.4 登添加验证码

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

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

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

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

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

  9. C# DateTime的11种构造函数 [Abp 源码分析]十五、自动审计记录 .Net 登陆的时候添加验证码 使用Topshelf开发Windows服务、记录日志 日常杂记——C#验证码 c#_生成图片式验证码 C# 利用SharpZipLib生成压缩包 Sql2012如何将远程服务器数据库及表、表结构、表数据导入本地数据库

    C# DateTime的11种构造函数   别的也不多说没直接贴代码 using System; using System.Collections.Generic; using System.Glob ...

随机推荐

  1. 点评js异步加载的4种方式

    主要介绍了点评js异步加载的4种方式,帮助大家更全面的了解js异步加载方式,感兴趣的小伙伴们可以参考一下 js异步加载的4种方式,点评开始. <!DOCTYPE html> <htm ...

  2. 项目管理:CocoaPods建立私有仓库

    CocoaPods是iOS,Mac下优秀的第三方包管理工具,类似于java的maven,给我们项目管理带来了极大的方便. 个人或公司在开发过程中,会积累很多可以复用的代码包,有些我们不想开源,又想像开 ...

  3. C#:简单线程样例

    1.定义线程类及内部事件 using System; using System.Collections.Generic; using System.Text; using System.Threadi ...

  4. java事务的类型——面试被问到

    Java事务的类型有三种:JDBC事务.JTA(Java Transaction API)事务.容器事务. 1.JDBC事务 JDBC 事务是用 Connection 对象控制的.JDBC Conne ...

  5. 【转】卸载VMware时提示“The MSI failed”解决方案

    转载地址: http://www.2cto.com/os/201309/243843.html   安装精简版VM后再安装其他版本的VM,或者想升级安装更高的版本时,无法正常卸载(如提示The MSI ...

  6. Android 自定义ScrollView ListView 体验各种纵向滑动的需求

      分类: [android 进阶之路]2014-08-31 12:59 6190人阅读 评论(10) 收藏 举报 Android自定义ScrollView纵向拖动     转载请标明出处:http: ...

  7. YTU 3002: 出栈顺序(栈和队列)

    3002: 出栈顺序(栈和队列) 时间限制: 1 Sec  内存限制: 128 MB 提交: 80  解决: 20 题目描述 给出一个入栈序列,和一个出栈序列,判断该出栈序列是否正确. 输入 输入包含 ...

  8. SlickGrid example 7:鼠标事件

    响应鼠标事件,可以左键快捷选择切换选项,可右键弹出菜单栏.   代码: <!DOCTYPE HTML> <html> <head> <meta http-eq ...

  9. poj1703 Find them, Catch them

    并查集. 这题错了不少次才过的. 分析见代码. http://poj.org/problem?id=1703 #include <cstdio> #include <cstring& ...

  10. poj3372 Candy Distribution

    可以证明: f(k) = k *(k - 1)/ 2 (1 ≤ k ≤ n)是n的完全剩余系当且仅当n = 2 ^ t. http://poj.org/problem?id=3372