. CN,zh;q=0.8', 'accept-encoding' => 'gzip, deflate', 'referer' => terima' => 'teks/html,aplikasi/xhtml+xml,aplikasi/xml;q=0.9,imej/webp,*/*;q=0.8', 'jenis kandungan' => www-form-urlencoded', 'user-agent' => 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, seperti Gecko) Chrome/56.0.2924.90 Safari/537.36 2345Explorer/17.3.2. -permintaan tidak selamat' => '1', 'asal' => 'http://a.com', 'cache-control' => > '23', 'sambungan' => 'tutup', 'hos' => > '123456', )
[ LIHAT ] E:phpStudyPHPTutorialWWWhycyapplicationindexviewuserlogin.html [ array ( 0 => 'title', ) ]
jika(Permintaan::isAjax()){
//
$data = Request::post();//获取ajax提交数据
$rule = ['nama|姓名'=> 'require|length:2,20|chsAlphaNum',
'password|密码'=>'require|alphaNum',];
$res=$this->validate($data,$rule) ;
jika (benar !== $res){ //验证失败
kembalikan ['status'=> -1, 'message'=>$res];
}lain { //验证成功
//2. 查询数据表zh_user中,并对结果进行判断
$result = Syuser::get(function($query) use ($data){
$data-['name-&g't; '])
->di mana('kata laluan',sha1($data['kata laluan']));
});
// berhenti($hasil); //测试查询结果
if(null == $result){
return ['status'=>0, 'message'=>'邮箱或密码不,正玜🎮 } lain{
//将用户ID写入session中
Session::set('user_id', $result->id);
Session::set('user_name', $result->name );
Sesi::set('is_admin', $result->is_admin);
return ['status'=>1, 'message'=>'恭喜,登录成功~~'];
}
}
}lain{
$this->error('请求类型错误','login');
}
}