<?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();
}
}