控制器
\Application\Admin\Controller\PublicController.class.php
~~~
<?php
namespace Admin\Controller;
use Think\Controller;
class PublicController extends Controller
{
//登录验证
public function login(){
if(IS_POST){
$map['account'] = I('account'); //用户名
$map['password'] = md5(I('password')); //密码
$info = D('Admin')->where($map)->find();
if (!$info) {
$this->ajaxReturn(['code'=>0,'msg'=>'账户或密码错误']);
}
if ($info['status'] == 0) {
$this->ajaxReturn(['code'=>0,'msg'=>'登录失败,账号被禁用']);
}
session('aid',$info['id']); //管理员ID
session('account',$info['account']);
//保存登录信息
$data['id'] = $info['id']; //用户ID
$data['login_time'] = time(); //最后登录时间
$data['login_count'] = $info['login_count'] + 1;
M('Admin')->save($data);
$notes = session('account').'于'.date('Y-m-d H:i:s',time()).'成功登录浩卓后台管理系统。';
// addmanagelog(1,$notes);
D('AdminLog')->update(1,$notes);
$this->ajaxReturn(['code'=>1,'msg'=>'登录成功']);
// $this->success('验证成功,正在跳转到首页',U('Index/index'));
}else{
if(session('aid')){
$this->redirect('Index/index');
}
$this->display();
}
}
}
~~~
登录页面
\Application\Admin\View\Public\login.html
~~~
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=">
<title>后台管理系统</title>
<link rel="stylesheet" href="__PUBLIC__/Admin/css/login.css">
<script src="__PUBLIC__/Admin/js/jquery-1.9.1.js"></script>
<script src="__PUBLIC__/Common/Layer/layer.js"></script>
</head>
<body>
<div class="main">
<div class="login">
<form id="loginform" method="post">
<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="30%" class="tdleble">用户名:</td>
<td width="60%">
<input type="text" name="account" class="infoInput" maxlength="20" value="" placeholder="请输入用户名" /></td>
</tr>
<tr>
<td height="36" class="tdleble">密 码:</td>
<td>
<input type="password" name="password" class="infoInput" value="" placeholder="请输入密码" /></td>
</tr>
<tr>
<td> </td>
<td>
<input type="submit" name="submit" value="登 录" class="subbottom" /></td>
</tr>
</table>
</form>
</div>
</div>
<script>// 刷新验证码
$(function() {
var verifyimg = $(".reloadverify").attr("src");
$(".reloadverify").click(function() {
if (verifyimg.indexOf('?') > 0) {
$(".reloadverify").attr("src", verifyimg + '&random=' + Math.random());
} else {
$(".reloadverify").attr("src", verifyimg.replace(/\?.*$/, '') + '?' + Math.random());
}
});
$("#loginform").submit(function(e){
var res = $(this).serialize();
var url = "{:U('Public/login')}";
$.ajax({
url: url,
data: res,
type: 'post',
success:function(data){
if (data.code == 1) {
layer.alert(data.msg,{icon:6},function (index) {
layer.close(index);
window.location.href = "{:U('Index/index')}";
});
} else{
layer.alert(data.msg,{icon:5},function (index) {
layer.close(index);
window.location.reload();
});
}
}
});
return false; // 阻止表单跳转
});
});
</script>
</body>
</html>
~~~
- php ping 地址
- python调用php脚本和sh调用php脚本
- php随机字符串
- redis操作
- 公共页面文件
- 登录
- 文章
- 文章管理
- 文章分类
- 图片
- 图片分类
- 图片管理
- 配置文件
- ueditor配置远程上传
- django
- 安装
- jinja2模板标签
- 虚拟机
- centos宝塔面板安装
- mysql主从搭建
- 虚拟机安装centos7
- 2
- 主从复制
- uni-app
- 更新
- 直播简单代码
- 搞笑的注释代码
- jwt
- centos以太坊环境搭建
- thinkphp5.1下的redis使用
- redis的安装
- tp5.1中使用
- tp5.1下载酷狗音乐
- 跨域
- tp5.1导出数据库到excel
- 钩子和行为
- 支付宝
- 申请支付宝app接入
- 视频播放
- 模块安装
- 推流配置
- pc端网页代码
- srs
- 后台布局
- 基础布局文件
- 左边
- 头部
- css特效代码
- 图片旋转
- 图片放大
- 顶部
- 列表页
- 更新数据表单页
- 模型获取器
- 上传图片
- mysql
- 一些常用
- 远程授权
- 数据库常用命令
- 忘记密码
- webpack
- 一些乱七八糟的东西
- linux后台运行脚本过大处理办法
- sublime插件
- linux svn安装
- 工具
- 查看进程
- 获取微信公众号文章
- 爬取微信公众号文章
- 清空nohup
- 服务器上跨域配置
- sql语句生成orm模型写法的工具
- centos换阿里源
- linux一些日志操作
- zsh