| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- <?php
- namespace app\index\controller;
- use think\Controller;
- use think\Session;
- use think\Db;
- use think\Request;
- class Login extends Controller
- {
- public function index()
- {
- return $this->fetch();
- }
-
- public function video()
- {
- return $this->fetch();
- }
- public function dologin()
- {
- $res=array();
- if ($this->request->isAjax()&&$this->request->isPost()) {
- $data = $_POST;
- $company=Db::name('company')->where('account',$data['username'])->find();
- if($company){
- if($company['password']==md5($data['password'])){
- session('uid',$company);//保存账号信息
- $res=array("status"=>1,"msg"=>'success');
- }else{
- $res=array("status"=>0,"msg"=>'密码错误');
- }
- }else{
- $res=array("status"=>0,"msg"=>'该账号不存在');
- }
- }else{
- $res=array("status"=>0,"msg"=>'非法请求');
-
- }
- echo json_encode($res);
- }
- public function logout()
- {
- session(null);
- $this->redirect('Login/index');
- }
- }
|