I have 3 table for first table user, $data i have $id and it's auto\_increment, and it like auto fill on mysql but the problem is the second table and the third $id is foreign key from first table, and when i insert the data, $id from the second table and the third table is empty, how i get $id for fill $id from the second table and the third?, here the code :

```
if($this->form_validation->run() == TRUE){
            echo 'Harap Tunggu...';
            //data akun
            $email = $this->input->post('email');
            $pass = md5($this->input->post('password'));

            //data pribadi
            $nama = $this->input->post('nama_lengkap');
            $alamat = $this->input->post('alamat');
            $tgl_lhr = $this->input->post('date');
            $no_telp = $this->input->post('no_telp');

            //data pendidikan
            $tingkat_pendidikan = $this->input->post('tingkat_pendidikan');
            $nama_institusi = $this->input->post('namainstitusi');
            $jurusan = $this->input->post('jurusan');
            $no_induk = $this->input->post('nomor_induk');
            $nilai = $this->input->post('nilai');
            $no_telpon_institusi = $this->input->post('no_institusi');

            $salt = $this->salt();

            $pass = $this->makePassword($this->input->post('password'), $salt);

            $data = array(
                'id' => $id,
                'email' => $email,
                'password' => $pass,
                'salt' => $salt
            );

            $data2 = array(
                'nama_lengkap' => $nama,
                'tanggal_lahir' => $tgl_lhr,
                'alamat' => $alamat,
                'no_telpon' => $no_telp,
                'id' => $id
                );

            $data3 = array(
                'tingkat_pendidikan' => $tingkat_pendidikan,
                'nama_institusi' => $nama_institusi,
                'jurusan' => $jurusan,
                'no_induk' => $no_induk,
                'nilai' => $nilai,
                'no_telpon_institusi' => $no_telpon_institusi,
                'id' => $id
                );

            $this->db->insert('user',$data);
            $id = $this->db->insert_id();
            $data2['id'] = $data3['id'] = $id;
            $this->db->insert('data_pribadi',$data2);
            $this->db->insert('pendidikan',$data3);

            $this->session->set_flashdata("success","your account has been created");
            $this->session->set_flashdata('id', $id);
            redirect('upload_foto/index','refresh');

        }

```