亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

thinkphp登錄操作模塊

原創(chuàng) 2019-03-10 14:04:54 311
摘要:<?phpnamespace app\index\controller;use think\Controller;class Login extends Controller{public function index(){return $this->fetch();}}在 application\inde

<?php

namespace app\index\controller;

use think\Controller;

class Login extends Controller

{

public function index()

{

return $this->fetch();

}

}

在 application\index\view 新建 login 文件夾,然后在其內(nèi)新建 index.hml


form 表單的提交地址填寫的地址是 login控制的 dologin

// 處理登錄邏輯

public function doLogin()

{

$param = input('post.');

if(empty($param['user_name'])){

$this->error('用戶名不能為空');

}

if(empty($param['user_pwd'])){

$this->error('密碼不能為空');

}

// 驗(yàn)證用戶名

$has = db('users')->where('user_name', $param['user_name'])->find();

if(empty($has)){

$this->error('用戶名密碼錯誤');

}

// 驗(yàn)證密碼

if($has['user_pwd'] != md5($param['user_pwd'])){

$this->error('用戶名密碼錯誤');

}

// 記錄用戶登錄信息

cookie('user_id', $has['id'], 3600); // 一個小時有效期

cookie('user_name', $has['user_name'], 3600);

$this->redirect(url('index/index'));

}


批改老師:韋小寶批改時間:2019-03-10 14:23:06
老師總結(jié):寫的還是很不錯的 有兩行注釋沒有注釋了哦 登錄這一塊的驗(yàn)證還是比較重要的

發(fā)佈手記

熱門詞條