public function add() { if (isset($_SESSION['name']) && $_SESSION['role'] == 1) { $Manager = new \Model\ManagerModel(); if (!empty($_POST)) { $z = $Manager->create(); if (!$z) { $this->error($Manager->getError() . '!', 'javascript:history.back();'); } else { $z = $Manager->add(); if ($z) { $this->success("添加管理员成功!", U('index')); } else { $this->error("添加管理员失败!", U('index')); } } } else { $this->assign('id', $_SESSION['id']); $this->assign('name', $_SESSION['name']); $this->assign('role', $_SESSION['role']); $front = D("Front"); $fid = 1; $resultByFront = $front->where('fid = ' . $fid)->find(); $this->assign('resultByFront', $resultByFront); $this->display(); } } else { $this->error("非法访问,你不是超级管理员!", U('Index/index')); } }
function login(){ if(!empty($_POST)){ //验证码校验 $verify = new \Think\Verify(); if(!$verify->check($_POST['captcha'])){ echo "验证码错误"; } else { //判断用户名和密码,在model模型里边制作一个专门方法进行验证 $user = new \Model\ManagerModel(); $rst = $user -> checkNamePwd($_POST['mg_username'],$_POST['mg_password']); if($rst === false){ echo "用户名或密码错误"; } else { //登录信息持久化$_SESSION session('mg_username',$rst['mg_name']); session('mg_id',$rst['mg_id']); //$this ->redirect($url, $params, $delay, $msg) //$this -> redirect('Index/index',array('id'=>100,'name'=>'tom'),2,'用户马上登陆到后台'); $this -> redirect('Index/index'); } } } $this -> assign('lang',L()); $this -> display(); }
function login() { //display()没有参数,那么获得的模板名称与当前操作的名称一致 //display('hello'); Admin/View/Manager/hello.html // show_bug(L()); $message = array(); if (!empty($_POST)) { //验证码校验 //show_bug($_POST); $VerifyIMG = new \Think\Verify(); if (!$VerifyIMG->check($_POST['captcha'])) { //echo '验证码错误'; $message[0] = '验证码错误'; } else { //echo '验证码正确'; $user = new \Model\ManagerModel(); $result = $user->CheckUP($_POST['admin_user'], $_POST['admin_psd']); if ($result != false) { //show_bug($result);exit(); session('username', $result['mg_name']); session('user_id', $result['mg_id']); //跳转方法 $this->redirect('Index/index'); } else { //echo '用户名或者密码错误'; $message[0] = '用户名或者密码错误'; } } } $this->assign('message', $message); $this->assign('lang', L()); //将语言传递到模板 $this->display(); }
public function checkManagerMessage() { //接收管理员信息并判断 if (!empty($_POST)) { //实例化管理员model对象 $manager = new \Model\ManagerModel(); //调用方法并传递信息 $info = $manager->checkMessage($_POST['name'], $_POST['pwd']); //判断,返回数组为真 if ($info) { //登陆成功,保存session session("admin_id", $info['ma_id']); session("admin_name", $info['ma_name']); //跳转至后台首页面 $this->redirect("Index/index"); } else { echo "<font color='red'>用户名或密码错误!</font>"; die; } } }
public function login() { if (!empty($_POST)) { $verify = new \Think\Verify(); if ($verify->check($_POST['captcha'])) { $manager = new \Model\ManagerModel(); $rst = $manager->checkManager($_POST['name'], $_POST['pswd']); if ($rst === false) { echo "用户名或密码错误"; } else { //登录信息持久化 session('mg_username', $rst['mg_name']); session('mg_id', $rst['mg_id']); $this->redirect('Index/Index'); } } else { echo "验证码错误,请重新输入"; } } else { $this->display(); } }
public function updpsd() { if (isset($_SESSION['name'])) { if (!empty($_POST)) { //判断密码与确认密码是否一致,不一致就提示再返回,为空也返回 if (empty($_POST['password']) || empty($_POST['password0'])) { $this->error('新密码不能为空!', U('index')); } if ($_POST['password'] != $_POST['password0']) { $this->error('密码与确认密码不一致!', U('index')); } //添加当前用户的id,name值到$_POST $_POST['id'] = $_SESSION['id']; $_POST['name'] = $_SESSION['name']; //将确认密码unset掉 unset($_POST['password0']); //密码要进行MD5加密 $_POST['password'] = MD5($_POST['password']); $Manager = new \Model\ManagerModel(); $Manager->create(); $z = $Manager->save(); if (!$z) { $this->error($Manager->getError() . '!', U('index')); } else { $this->success("修改密码成功!", U('index')); } } else { $this->assign('id', $_SESSION['id']); $this->assign('name', $_SESSION['name']); $this->assign('role', $_SESSION['role']); $front = D("Front"); $fid = 1; $resultByFront = $front->where('fid = ' . $fid)->find(); $this->assign('resultByFront', $resultByFront); $this->display(); } } else { $this->error("非法访问,请登录后重试!", U('Login')); } }