TP框架中的一些登录代码分享

Posted 白云千载空悠悠

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了TP框架中的一些登录代码分享相关的知识,希望对你有一定的参考价值。

<?php
namespace Admin\Controller;
use Think\Controller;
class LoginController extends Controller{
public function login(){

if(IS_POST){
$data = I(‘post.‘);
$verify = new \Think\Verify();
if(!$verify ->check($data[‘code‘]) ){
$this->error(‘验证码错误‘);
}
$model = D(‘Manager‘);
$manager =$model->where(array(‘username‘=>$data[‘username‘]))->find();
if($manager && encrypt_password($data[‘password‘])== $manager[‘password‘] ){
session(‘manager_info‘,$manager);
$this->success(‘登陆成功‘,U(‘Admin/Index/index‘));
}else{
$this ->error(‘登录失败‘);
}

}else{
$this ->display();
}
}


public function logout(){
session(null);
$this ->redirect(‘Admin/Login/login‘);
}

public function captcha(){
$config =array(
‘length‘=>4,
‘useCurve‘=>false,
‘useNoise‘=>false,
);

$verify =new \Think\Verify($config);
$verify ->entry();
}

}

以上是关于TP框架中的一些登录代码分享的主要内容,如果未能解决你的问题,请参考以下文章

tp5更改入口文件到根目录的方法分享

分享一个爬虫框架

接口测试业务验证--视频演示

分享一个PHP抽奖算法程序代码

Android应用之——微信微博第三方sdk登录分享使用过程中的一些常见问题

RxJava的一些入门学习分享