Welcome Guest, Not a member yet? Register   Sign In
Login
#14

[eluser]Felipe Deitos[/eluser]
Thanks for all your answers dude...
I am using that Template that you teached me...

I changed the way i validate de user, because i am storing the lvl(level) of the user in the session...
I dont know if what i am doing are the best pactices, but its working...

controller:
Code:
public function validate_user()
{
  $this->load->model('users_model');
  $data = $this->users_model->validate();
  
  if($data['is_logged'])
  {  
   $this->session->set_userdata($data);
   redirect($this->input->post('current_url'));
  }
  else
  {
   redirect($this->input->post('current_url'));
  }
}

model:
Code:
public function validate()
{
  $this->db->where('user', $this->input->post('user'));
  $this->db->where('password', md5($this->input->post('password')));
  $query = $this->db->get('users');
  
  // return ($query->num_rows == 1);
  
  if($query->num_rows == 1)
  {
   $data = array(
    'user' => $query->row('user'),
    'lvl' => $query->row('lvl'),
    'is_logged' => true
   );
   return ($data);
  }
  else
  {
   $data = array(
    'is_logged' => false
   );
   return ($data);
  }
}

The problem is... as you can see in the controller, if the 'is_logged' = false i just redirect the user to the current_url... i want to pass and error message with it... how can i do that using the Template style that you showed me?

Thanks again for all the help!


Messages In This Thread
Login - by El Forum - 07-11-2012, 09:58 AM
Login - by El Forum - 07-11-2012, 10:24 AM
Login - by El Forum - 07-11-2012, 11:16 AM
Login - by El Forum - 07-11-2012, 11:41 AM
Login - by El Forum - 07-11-2012, 11:55 AM
Login - by El Forum - 07-11-2012, 12:08 PM
Login - by El Forum - 07-11-2012, 12:25 PM
Login - by El Forum - 07-11-2012, 12:33 PM
Login - by El Forum - 07-11-2012, 12:39 PM
Login - by El Forum - 07-11-2012, 01:42 PM
Login - by El Forum - 07-11-2012, 01:46 PM
Login - by El Forum - 07-12-2012, 04:19 AM
Login - by El Forum - 07-12-2012, 10:52 AM
Login - by El Forum - 07-12-2012, 12:05 PM
Login - by El Forum - 07-12-2012, 12:12 PM
Login - by El Forum - 07-12-2012, 12:31 PM



Theme © iAndrew 2016 - Forum software by © MyBB