验证方面写的不是很完整,正在完善当中
/**
* 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'));
}
}
前台页面
登录(Login)* { margin:0; padding:0; }
body { background:#111; height:100%; }
img { border:none; }
#supersized-loader { position:absolute; top:50%; left:50%; z-index:0; width:60px; height:60px; margin:-30px 0 0 -30px; text-indent:-999em; background:url("__PUBLIC__/admin/login/img/progress.gif") no-repeat center center;}
#supersized { display:block; position:fixed; left:0; top:0; overflow:hidden; z-index:-999; height:100%; width:100%; }
#supersized img { width:auto; height:auto; position:relative; display:none; outline:none; border:none; }
#supersized.speed img { -ms-interpolation-mode:nearest-neighbor; image-rendering: -moz-crisp-edges; }/*Speed*/
#supersized.quality img { -ms-interpolation-mode:bicubic; image-rendering: optimizeQuality; }/*Quality*/
#supersized li { display:block; list-style:none; z-index:-30; position:fixed; overflow:hidden; top:0; left:0; width:100%; height:100%; background:#111; }
#supersized a { width:100%; height:100%; display:block; }
#supersized li.prevslide { z-index:-20; }
#supersized li.activeslide { z-index:-10; }
#supersized li.image-loading { background:#111 url("__PUBLIC__/admin/login/img/progress.gif") no-repeat center center; width:100%; height:100%; }
#supersized li.image-loading img{ visibility:hidden; }
#supersized li.prevslide img, #supersized li.activeslide img{ display:inline; }
#supersized img { max-width: none !important }
梦起工作室后台登录(Login)
登录