?LANG ] E:phpStudyPHPTutorialWWWhycythinkphplangzh-cn.php
[ ROUTE ] ?? ( )
[ HEADER ] ?? ( '??' => 'thinkphp_show_page_trace=1|2', 'accept-??' => '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' => www-form-urlencoded', 'user-agent' => 'Mozilla/5.0(Windows NT 6.1) AppleWebKit/537.36(KHTML, like Gecko) Chrome/56.0.2924.90 Safari/537.36 2345Explorer/9.3.2.17331', '????? -insecure-requests' => '1', 'origin' => 'http://a.com', 'cache-control' => 'max-age=0', 'content-length' = > '23', '??' => '??', '???' => 'a.com', )
[ PARAM ] ?? ( '??' => 'jh', '????' = > '123456', )
[ ?? ] E:phpStudyPHPTutorialWWWhycyapplicationindexviewuserlogin.html [ ?? ( 0 => '??', ) ]
if(??::isAjax()){
//數(shù)據(jù)驗(yàn)證
$data = ??::post();//獲取ajax提交數(shù)據(jù)
$rule = ['name|姓name'=> 'require|??:2,20|chsAlphaNum',
'password|密碼'=>'require|alphaNum',];
$res=$this->validate($data,$rule) ;
if (true !== $res){ ?//驗(yàn)證失敗
? return ['status'=> -1, 'message'=>$res];
? }else { //驗(yàn)證成功
? //2. 查詢數(shù)據(jù)表zh_user中,并對(duì)結(jié)果進(jìn)行判斷
? $result = Syuser::get(function($query) use ($data){
? $query->where('name',$data['name '])
? ?->where('password',sha1($data['password']));
? });
? // ??($result); //測(cè)試查詢結(jié)果
? if(null == $result){
? return ['status'=>0, 'message'=>'郵箱或密碼不正確,請(qǐng)檢查~~'];
} else{
//將用戶ID寫入session中
Session::set('user_id', $result->id);
Session::set('user_name', $result->name );
??::set('is_admin', $result->is_admin);
return ['status'=>1, 'message'=>'恭喜,登錄成功~~'];
}
} ?
}else{
$this->error('請(qǐng)求類型錯(cuò)誤','login');
}
???? ???? ??? ??? ????? AJAX ??? ??? ?? ????. ???? ??? ?? JS ??? ?????.