Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- LOGIN CONTROLLER
- -----------------------------------------------------------------------------------
- public function login()
- {
- if(isset($_POST['login_btn'])){
- $username = $_POST['userid'];
- $password = $_POST['psw'];
- $this->load->model('user_model');
- $fetch = $this->user_model->login_user($username, $password);
- if($fetch){
- $this->welcome();
- }else{
- $this->load->view('login');
- }
- }else
- $this->load->view('login');
- /*
- */
- }
- ------------------------------------------
- LOGIN MODEL
- -----------------------------------------
- public function login_user($username, $password){
- $user = $username;
- $this->db->select('user_id, password, username');
- $this->db->from('user');
- $this->db->where('username', $username);
- $query = $this->db->get();
- $res = $query->row_array();
- $result = password_verify($password, $res['password']);
- if($query -> num_rows() == 1){
- if(password_verify($password, $res['password'])){
- $_SESSION['userid'] = $res['username'];
- $_SESSION['logged'] = true;
- return 1;
- }
- else{
- $_SESSION['message'] = "Username/Password combination doesn't match.";
- return 0;
- }
- }else{
- $_SESSION['message'] = "Account doesn't exist.";
- return 0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement