Welcome Guest, Not a member yet? Register   Sign In
[Solved] $user_query not returning row in library
#1

[eluser]riwakawd[/eluser]
My login function in my Users library is not getting the $user_query row. I thought I got this correct.

Code:
$data = array(
    'user_id' => $this->user_id,
    'username' => $this->username
);

$this->CI->session->set_userdata($data);

$this->CI->session->userdata('user_id') = $user_query->row('user_id');

$this->user_id = $user_query->row('user_id');
$this->username = $user_query->row('username');

User.php Library

Code:
public function login() {

$user_query = $this->CI->db->query("SELECT * FROM " . $this->CI->db->dbprefix . "user WHERE username = '" . $this->CI->db->escape($username) . "' AND (password = SHA1(CONCAT(salt, SHA1(CONCAT(salt, SHA1('" . $this->CI->db->escape($password) . "'))))) OR password = '" . $this->CI->db->escape(md5($password)) . "') AND status = '1'");

if ($user_query->num_rows() == 1) {

$data = array(
    'user_id' => $this->user_id,
    'username' => $this->username
);

$this->CI->session->set_userdata($data);

$this->CI->session->userdata('user_id') = $user_query->row('user_id');

$this->user_id = $user_query->row('user_id');
$this->username = $user_query->row('username');  

$user_group_query = $this->CI->db->query("SELECT permission FROM " . $this->CI->db->dbprefix . "user_group WHERE user_group_id = '" . (int)$user_query->row('user_group_id') . "'");

$permissions = unserialize($user_group_query->row('permission'));

if (is_array($permissions)) {
    foreach ($permissions as $key => $value) {
    $this->permission[$key] = $value;
  }
}

return true;

} else {

return false;

}
    
}



Messages In This Thread
[Solved] $user_query not returning row in library - by El Forum - 06-14-2014, 02:54 AM
[Solved] $user_query not returning row in library - by El Forum - 06-14-2014, 06:09 AM
[Solved] $user_query not returning row in library - by El Forum - 06-17-2014, 02:16 PM



Theme © iAndrew 2016 - Forum software by © MyBB