Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class User_model extends CI_Model
- {
- private $_table = "user";
- public $user_id;
- public $nama;
- public $password;
- public $email;
- public $alamat;
- public $role;
- public function rules()
- {
- return [
- ['field' => 'password',
- 'label' => 'Password',
- 'rules' => 'required|min_length[3]'],
- ['field' => 'email',
- 'label' => 'Email',
- 'rules' => 'required|valid_email']
- ];
- }
- public function doLogin(){
- $post = $this->input->post();
- $this->db->where('email', $post["email"]);
- $user = $this->db->get($this->_table)->row();
- if($user){
- $isPasswordTrue =0;
- if($post["password"]== $user->password) $isPasswordTrue =1;
- // $isPasswordTrue = password_verify($post["password"], $user->password);
- // $isAdmin = $user->role == "1";
- if($isPasswordTrue){
- $this->session->set_userdata(['user_logged' => $user]);
- return true;
- }
- }
- return false;
- }
- public function isNotLogin(){
- return $this->session->userdata('user_logged') === null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement