Nasıl oturumuna olmayan sonrası veri göndermek için zaman kullanıcı günlüklerine

0 Cevap php

Benim oturum verileri sonrası veri almak ve benim veritabanında oturum tabloya göndermek için kodlanmış çünkü benim kullanıcıların ilk isim, soyadı ve kimlik oturum verileri eksik web sitesine giriş yaptığınızda.

Kullanıcı benim oturum verileri e-posta ve şifre ile oturum Çünkü sadece e-posta görünür ve başka bir şey yok.

Nasıl ilk adını, soyadını ve id yapabilirsiniz benim db benim oturum tablosunda görünür? Biraz istiyorum nasıl kullanıcı oturum olduğunda veritabanından bu bilgileri kapmak ve onun yükleme giriş başarısını yayınlanmıştır olsun benim $ u_data dizisinde bunu sağlamak.

İşte benim kod:

<?php
class Login_Model extends CI_Model {


    public function checkLogin() {

            $this->db->where('email', $this->input->post('email')); //compare db email to email entered in form
            $this->db->where('password', $this->hashed()); //compare db password to hashed user password
            $query = $this->db->get('users'); //get the above info from 'user' table

            if ($query->num_rows() == 1) { //if number of rows returned is 1

            $u_data = array( //new variable with session data
                'user_id' => $this->db->insert_id(),
                'email' => $this->input->post('email'),
                'first_name' => $this->input->post('first_name'),
                'last_name' => $this->input->post('last_name'),
                'logged_in' => TRUE
            );

            $this->session->set_userdata($u_data); //send data from variable to db session
            return TRUE;

       } else {
            return FALSE;
       }
 }


   public function hashed() { //hashing method

            // sha1 and salt password
            $password = $this->encrypt->sha1($this->input->post('password')); //encrypt user password
            $salt = $this->config->item('encryption_key'); //grab static salt from config file

            $start_hash = sha1($salt . $password);
            $end_hash = sha1($password . $salt);
            $hashed = sha1($start_hash . $password . $end_hash);
            return $hashed;
}

}

alt text

0 Cevap