LANG ] E:\phpStudy\PHPTutorial\WWW\hycy\thinkphp\lang\zh-cn.php
[ ROUTE ] array ( )
[ HEADER ] array ( 'cookie ' => 'thinkphp_show_page_trace=1|2', 'accept-language' => 'zh-CN,zh;q=0.8', 'accept-encoding' => 'gzip, deflate', 'referer' = > 'http ://a.com/index.php/index/user/login', '接受' => 'text/html,application/xhtml xml,application/xml;q=0.9,image/webp, */*;q =0.8', 'content-type' => 'application/x-www-form-urlencoded', 'user-agent' => 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 ( KHTML,如Gecko) Chrome/ 56.0.2924.90 Safari/537.36 2345Explorer/9.3.2.17331', 'upgrade-insecure-requests' => '1', 'origin' => 'http://a.com', 'cache-control' => 'max -age=0', 'content-length' => '23', '連線' => '關閉', '主機' => 'a.com', )
[ PARAM ] array ( ' name' => 'jh', 'password' => '123456', )
[ VIEW ] E:\phpStudy\PHPTutorial\WWW \hycy\application\index\view\user\login.html [ array ( 0 => 'title', ) ]
if(Request::isAjax()){
/ /資料驗證
$data = Request::post ();//取得ajax提交資料
$rule = ['name|姓名'=> 'require|length:2,20|chsAlphaNum',
'密碼|密碼'=>'require|alphaNum',];
# $res=$ this ->validate($data,$rule);
if (true !== $res){ //驗證失敗
return ['status'=>; -1, 'message'=>$res];
}else { //驗證成功
//2.查詢資料表zh_user中,文獻結果進行判斷
$result = Syuser::get(function($query) use ($data){
$query->where('名稱' ,$data['名稱'])
->where('密碼',sha1($data['密碼']));
});
// 暫停($結果); //測試查詢結果
if(null == $result){
return ['status'=>0, 'message'=>'郵箱或密碼不正確,請檢查~ ~'];
} else{
//將使用者ID寫入session中
Session::set('user_id', $result-> id);
Session::set('user_name', $result->name);
# Session::set('is_admin', $result->is_admin);
return ['status'=>1, 'message'=>'恭喜,登入成功~~'];
}
}
}else{
# $this->error('請求類型錯誤','login');
}
點登陸沒反映應該是前端AJAX 寫的有問題 開啟瀏覽器控制 台 檢查 JS的錯誤