因此,我想创建一些登录页面,然后在登录成功后在仪表板上显示用户名。但是名称不会显示在仪表板上。它只是空白。没有错误通知之类的。请帮忙。谢谢我在PHP 7上运行Auth.php控制器public function index(){ $this->form_validation->set_rules('email','email', 'trim|required|valid_email'); $this->form_validation->set_rules('password','Password','trim|required'); if($this->form_validation->run() == false){ $data['title']='Login Page'; $this->load->view('templates/auth_header', $data); $this->load->view('auth/login'); $this->load->view('templates/auth_footer'); } else{ //success validation $this->_login(); }}private function _login(){ $email = $this->input->post('email'); $password = $this->input->post('password'); $user = $this->db->get_where('user',['email' => $email])->row_array(); if($user){ //user active if($user['is_active']==1){ //check password if(password_verify($password, $user['password'])){ //if pass were right $data = [ 'email' => $user['email'], 'role_id' => $user['role_id'] ]; $this->session->set_userdata('$data'); redirect('user'); } else{ $this->session->set_flashdata('message','<div class="alert alert-danger" role="alert"> Wrong password</div>'); redirect('auth'); } } else{ // $this->session->set_flashdata('message','<div class="alert alert-danger" role="alert"> Email has not been activated</div>'); redirect('auth'); } } else{ //no email in database $this->session->set_flashdata('message','<div class="alert alert-danger" role="alert"> Email is not registered</div>'); redirect('auth'); }}和用于在页面中显示数据的命令
1 回答
慕容森
TA贡献1853条经验 获得超18个赞
也许您的错误是Auth-> _ login()行中的Here set_userdata
,请
替换
$this->session->set_userdata('$data');
和
$this->session->set_userdata($data);
- 1 回答
- 0 关注
- 129 浏览
添加回答
举报
0/150
提交
取消