控制器
\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