checking user login in codeigniter

Now we are going to check that the user name and password we entered in the form is valid or not by checking the database. Here I changed the login_process function as follows :

   public function login_process()
   {
     if($this->input->post('u_login'))
     {
       $u_name=$this->input->post('u_name');
       $u_pass=md5($this->input->post('u_password'));
       $u_data=array('u_name'=>$u_name,'u_pass'=>$u_pass);
       $users_list=$this->db->get_where('users',array('u_name'=>$u_data['u_name']));
       foreach($users_list->result() as $users)
       {
        if($u_data['u_name']==$users->u_name && $u_data['u_pass']==$users->u_pass)
        {
          echo "success";
        }
        else
        {
          echo "failed";
        }
       }
     }
     else
     {
       redirect('login','refresh');
     }
   }
















Comments

Popular posts from this blog

Node.js Cheat Sheet

Codeigniter ! Simple But Powerful

Bootstrap ? What is it ?