Welcome Guest, Not a member yet? Register   Sign In
function check
#1

[eluser]Gabi3xz[/eluser]
Hello i have a function for select id, email, password for check login
Code:
//function check
function check_user($email, $password) {
$q = $this->db
          ->select('id', 'email_address', 'password')
          ->where('email_address', $email)
          ->where('password', sha1($password))
          ->limit(1)
          ->get('users');
          
          return $q->row();

//call function for check login
$result = $this->call_db->check_user($this->input->post('email_address'),$this->input->post('password'));
How can extract id for set in session?
#2

[eluser]sanir[/eluser]
Code:
//function check
function check_user($email, $password) {
$q = $this->db
          ->select('id', 'email_address', 'password')
          ->where('email_address', $email)
          ->where('password', sha1($password))
          ->limit(1)
          ->get('users');
          
        if ($q->num_rows() > 0) {
            $row = $q->row_array();
            return  $row['id']) {
}

        

//call function for check login
$result = $this->call_db->check_user($this->input->post('email_address'),$this->input->post('password'));
Try this code.

Thanks,
Nasir Ranta
#3

[eluser]Gabi3xz[/eluser]
and what added here return $row['id']) {?}
#4

[eluser]sanir[/eluser]
Code:
//function check
function check_user($email, $password) {
$q = $this->db
          ->select('id', 'email_address', 'password')
          ->where('email_address', $email)
          ->where('password', sha1($password))
          ->limit(1)
          ->get('users');
          
        if ($q->num_rows() > 0) {
            $row = $q->row_array();
            return  $row['id'];
        }

}

        

//call function for check login
$result = $this->call_db->check_user($this->input->post('email_address'),$this->input->post('password'));

Use this code
#5

[eluser]LuckyFella73[/eluser]
After that line:
Code:
$result = $this->call_db->check_user($this->input->post('email_address'),$this->input->post('password'));

You can access the ID by:
Code:
$id = $result->id;

For better understanding when looking at the code later you could write
Code:
$row = $this->call_db->check_user($this->input->post('email_address'),$this->input->post('password'));

// and then:
$id = $row->id

Just a personal preference ..




Theme © iAndrew 2016 - Forum software by © MyBB