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', '接受' => '文本/html,application/xhtml+xml,application/xml;q=0.9,image/webp ,*/*;q=0.8', '内容类型' => 'application/x-www-form-urlencoded', '用户代理' => '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' , '缓存控制' => 'max-age=0', '内容长度' => '23', '连接' => 'a.com' , )
[ PARAM ] array ( 'name' => 'jh', 'password' => '123456', )
[ VIEW ] E:\phpStudy\PHPTutorial\ WWW\hycy\application\index\view\user\login.html [ array ( 0 => '标题', ) ]
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的错误