Solved it.
I was so totally dumb for not reading carefully what the use of password_verify() on PHP Manual. Well I finally get it right now. Here's my answer to my question an Updated One.
Code:
public function login(){
$this->load->library('form_validation');
$this->form_validation->set_rules('username', 'Username', 'required|trim');
$this->form_validation->set_rules('password', 'Password', 'required|trim');
$username = $this->input->post('username');
$password = $this->input->post('password');
$user_id ="";
if($this->form_validation->run()!= true){
redirect('Ec_controller/index');
}else{
$sql2 = $this->db->select("log_username, log_password,log_userlevel ")
->from("ec_login")
->where("log_username", $username)
->get();
foreach($sql2->result() as $user_level){
$user_id = $user_level->log_userlevel;
$user_password_db = $user_level->log_password;
}
$data = array(
'log_username' =>$username,
'log_userlevel' =>$user_id,
'log_password' =>$user_password_db,
'is_logged_in' =>1
);
$this->session->set_userdata($data);
if(password_verify($password,$user_password_db) && $user_id == 1){
redirect('Ec_controller/view_admin');
}elseif (password_verify($password,$user_password_db) && $user_id == 2) {
redirect('Ec_controller/view_it');
}else{
redirect("Ec_controller/index");
}
}
}
This gives me headache but that was worth it and I'm happy for the outcome. Sorry about that mate..