thinkphp与mysql登录验证_ThinkPHP之登录验证

验证方面写的不是很完整,正在完善当中

/**

* 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)

Verifys')%7D

登录

+
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值