<?php /** * Created by dreamcms. * User: Administrator * Date: 2016/9/5 * Time: 17:15 */ namespace Admin\Controller; use Think\Controller; class LoginController extends CommonController{ //视图显示 public function Login(){ $this->display(); } /** * 登录验证 */ public function Check_Login(){ //验证码检测 $names=$_POST['Captcha']; if($this->check_verify($names)==false){ $data['error']=1; $data['msg']="验证码错误"; $this->ajaxReturn($data); } //用户检测 $uname=I('post.username'); $upasswd=I('post.password'); $map['uname']=$uname; $map['state']=1; $logins=M('login')->where($map)->find(); if($logins) { if($logins['upasswd']!=$upasswd) { $data['error']=1; $data['msg']="密码错误"; $this->ajaxReturn($data); } session("admin",$logins); var_dump($logins); redirect(U('Index/index')); } } /** * 验证码生成 */ public function Verifys() { $config=array( 'fontSzie'=>30, //验证码字体大小 'length'=>4,//验证码位数 'useImgBg'=>true ); $verify=new \Think\Verify($config); $verify->useZh=true; $verify->zhSet="梦起软件工作室"; $verify->fontttf='simhei.ttf'; $verify->entry(); } /** * 验证码检测 */ public function check_verify($code,$id="") { $verify=new \Think\Verify(); return $verify->check($code,$id); } /** * 退出登录 */ public function out_login(){ session("admin",null); redirect(U('Login/login')); } }