Welcome Guest, Not a member yet? Register   Sign In
Best way of retrieving primary key
#12

[eluser]jeremydt[/eluser]
Well, I tested that code but it wouldn't work for me. I got the code below to work... is there too much redundant code?

Code:
function validate() {
        
        $this->db->where('user_username', $this->input->post('username'));
        $this->db->where('user_password', md5($this->input->post('password')));
        $q = $this->db->get('user');
        
        foreach ($q->result() as $row) {
            $username = $row->user_username;
            $userid = $row->user_id;
        }        
        
        if($q->num_rows == 1) {
            $data = array(
                'is_logged_in' => true,
                'userid' => $userid,
                'username' => $username
            );
            
            $this->session->set_userdata($data);
            return true;
        }
    }


Messages In This Thread
Best way of retrieving primary key - by El Forum - 09-21-2010, 06:05 AM
Best way of retrieving primary key - by El Forum - 09-21-2010, 06:19 AM
Best way of retrieving primary key - by El Forum - 09-21-2010, 06:29 AM
Best way of retrieving primary key - by El Forum - 09-21-2010, 06:30 AM
Best way of retrieving primary key - by El Forum - 09-21-2010, 06:32 AM
Best way of retrieving primary key - by El Forum - 09-21-2010, 06:46 AM
Best way of retrieving primary key - by El Forum - 09-21-2010, 07:05 AM
Best way of retrieving primary key - by El Forum - 09-21-2010, 09:33 AM
Best way of retrieving primary key - by El Forum - 09-21-2010, 09:49 AM
Best way of retrieving primary key - by El Forum - 09-21-2010, 10:24 AM
Best way of retrieving primary key - by El Forum - 09-21-2010, 10:24 PM
Best way of retrieving primary key - by El Forum - 09-22-2010, 07:57 AM
Best way of retrieving primary key - by El Forum - 09-22-2010, 10:12 AM



Theme © iAndrew 2016 - Forum software by © MyBB