In my CodeIgniter project, when the login button is clicked, it's not redirecting to the user home page. But for my client, it is working well.
When I use the print_r($query) it displays the following error:
CI_DB_mysql_result Object (
[conn_id] => Resource id #32
[result_id] => Resource id #38 >
[result_array] => Array ( )
[result_object] => Array ( )
[current_row] => 0
[num_rows] => 0
[row_data] =>
)
I have tried result() at the end of my code, but it's still its not working. How do I solve this issue?
My Controller Code is as follows:
<?php
class Main extends Controller
{
function Main()
{
parent::Controller();
}
function index()
{
$errMsg = '' ;
if ($this->input->post('adminUsername') && $this->input->post('adminPassword')) {
$user_name = $this->input->post('adminUsername');
$pass_word = base64_encode($this->input->post('adminPassword'));
$query = $this->db->get_where(
'gm_adminusers',
array(
'adminUsername' => $user_name,
'adminPassword' => $pass_word,
'admin_status' => 'A'
)
);
print_r($query);
if ($query->num_rows() > 0) {
$arrRow = $query->row_array();
$newdata = array(
'sess_adminId' => $arrRow['adminId'],
);
$this->db_session->set_userdata($newdata);
if ($this->db_session->userdata('sess_adminId')) {
redirect('user/home');
} else {
errMsg = '<span style="color:red">Login Error :Please Check Your input.</span>';
/*redirect('user/home'); */
}
} else {
$errMsg = '<span style="color:red">Critical Error:Contact Your Administrator</span>';
}
}
$data['errMsg'] = $errMsg;
$this->load->view('header');
$this->load->view('index', $data);
$this->load->view('footer');
}


base64_encodeis secure.base64_encodeis NOT a safe/secure way to hash passwords. CodeIgniter includes libraries to help deal with this, and there are many other libraries out there built for the purpose (bcrypt). Please see ellislab.com/codeigniter%20/user-guide/libraries/… and stackoverflow.com/a/7045061/183254$this->output->enable_profiler(TRUE);in your controller so that you can see the queries being run on your database. You can then check to query to debug why it is returning zero rows.123456. I don't think that decodes to 6 characters (which is what you typed in the password box).