Home  >  Article  >  Backend Development  >  Thinkphp框架拓展包使用模式详细介绍-验证码实例(十一)

Thinkphp框架拓展包使用模式详细介绍-验证码实例(十一)

WBOY
WBOYOriginal
2016-06-13 12:11:191088browse

Thinkphp框架拓展包使用方式详细介绍--验证码实例(十一)

拓展压缩包的使用方式详细介绍


  1:将拓展包解压:ThinkPHP3.1.2_Extend.zip   --> 将其下的 \Extend  文件全部复制

  

   2:将复制的文件放入项目中 E:\wamp\www\thinkphp\ThinkPHP\Extend(安装的时候这里面是空文件),你自己的项目目录

 即可

  

=============================以下是,拓展包中验证码的使用======================================== 

 比如用到拓展包的验证码:(看手册-->杂项)

  在:E:\wamp\www\thinkphp\Home\Lib\Action\ 新建:PublicAction.class.php  代码如下  --必须加

//直接使用code里面的代码即可生成验证码

class PublicAction extends Action{  //按照手册说明走就行

function code(){
import('ORG.Util.Image');
Image::buildImageVerify();
}

}


//目录/thinkphp/index.php/Public/code点击变换验证码onclick

前台模板页面调用验证码:

Thinkphp框架拓展包使用模式详细介绍-验证码实例(十一) 即可生成验证码


全部html登录页面

用户名:

密 码:

验证码:
Thinkphp框架拓展包使用模式详细介绍-验证码实例(十一)
/>
Thinkphp框架拓展包使用模式详细介绍-验证码实例(十一)

        


//登录判断验证码  加:LoginAction.class.php(模块)


class LoginAction extends Action {
function do_login(){
//获取用户名和密码等。和数据库中比对,有该用户允许登录否则输出错误页面
$username=$_POST['username'];
$password=$_POST['password'];
$code=$_POST['code'];  //输入框;

if($_SESSION['verify']!==md5($code)){
$this->error('验证码错误!');
}


$m=M('User');
$where['username']=$username;
$where['password']=$password;
$i=$m->where($where)->count();
if($i>0){
$this->redirect('User/index');
}else{
$this->error('该用户不存在');
}
}
}
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn