Cara input dari table 1 dan di masukan ke table 2?

gan jadi gini ane mau bikin form konfirmasi, jadi ketika user klik detail nanti bakal masuk ke form dan form itu isinya dari data table 1 nah form itu nantiny bakal punya tombol kirim tapi ane mau ketika submit dia masukny ke table 2 yang udah ane bikin khusus buat form konfirmasi, dan itu bisa ga ya? ane dah coba ane kirim datany pake $id ane pake codeiginter tapi eror "to few arguments" katany itu kan kalo ga salah karena $id ny ini, gmna ya gan adakah contoh kasusny?

public function order()
    {
        $data['title'] = 'Orderan';

        $data['user'] = $this->db->get_where('user', ['id' => $this->session->userdata('email_id')])->row_array();
        $data['user'] = $this->db->get_where('user', ['firstName' => $this->session->userdata('author')])->row_array();
        $data['user'] = $this->db->get_where('user', ['email' => $this->session->userdata('email')])->row_array();

        $this->load->model('PostModel', 'post');
        $data['order'] = $this->post->getOrder(2, 1);
        $this->load->helper('string');

        $data['nama_brg'] = $this->db->get('barang')->result_array();

        $this->form_validation->set_rules('pelanggan', 'Nama Anda', 'required');
        $this->form_validation->set_rules('alamat', 'Alamat', 'required');
        $this->form_validation->set_rules('nm_barang', 'Nama Barang', 'required');
        $this->form_validation->set_rules('jumlah', 'Jumlah', 'required');

        if ($this->form_validation->run() == false) {

            $this->load->view('templates/user-header', $data);
            $this->load->view('templates/user-sidebar', $data);
            $this->load->view('templates/user-topbar', $data);
            $this->load->view('user/order', $data);
            $this->load->view('templates/user-footer');
        } else {

            $id = $this->input->post('id_order');
            $pelanggan = $this->input->post('pelanggan');
            $alamat = $this->input->post('alamat');
            $jumlah = $this->input->post('jumlah');
            $tgl = $this->input->post('tgl_kirim');
            $nm_barang = $this->input->post('nm_barang');
            $id_plg = $this->input->post('id_pelanggan');
            $status = $this->input->post('status');

            $data = [
                'id_order' => rand(1000, 10000000),
                'pelanggan' => $pelanggan,
                'alamat' => $alamat,
                'jumlah' => $jumlah,
                'tgl_kirim' => $tgl,
                'nm_barang' => $nm_barang,
                'id_pelanggan' => $id_plg,
                'status' => $status,

            ];

            $this->db->insert('order_brg', $data);
            $this->session->set_flashdata('message', '<div class="alert alert-success" role="alert">Please wait admin approve your post</div>');
            redirect('user/order');
        }
    }

ane mau ambil dari database ini dan controler ini nah pas di submit ane mau masukny dia ke database pembayaran ini

public function pembayaran($id)
    {
        $data['title'] = 'Pembayaran';

        $data['user'] = $this->db->get_where('user', ['id' => $this->session->userdata('email_id')])->row_array();
        $data['user'] = $this->db->get_where('user', ['firstName' => $this->session->userdata('author')])->row_array();
        $data['user'] = $this->db->get_where('user', ['email' => $this->session->userdata('email')])->row_array();
        $data['order_brg'] = $this->db->get_where('order_brg', ['id_order' => $this->session->userdata('id_order')])->row_array();

        $this->load->helper('string');
        $this->load->model('PostModel', 'post');
        $data['order'] = $this->post->getTotal($id);

        $data['nama_brg'] = $this->db->get('barang')->result_array();
        $data['kode'] = $this->db->get('stats')->row_array();

        $this->form_validation->set_rules('pelanggan', 'Nama Anda', 'required');
        $this->form_validation->set_rules('alamat', 'Alamat', 'required');
        $this->form_validation->set_rules('nm_barang', 'Nama Barang', 'required');
        $this->form_validation->set_rules('jumlah', 'Jumlah', 'required');

        if ($this->form_validation->run() == false) {

            $this->load->view('templates/user-header', $data);
            $this->load->view('templates/user-sidebar', $data);
            $this->load->view('templates/user-topbar', $data);
            $this->load->view('user/pembayaran', $data);
            $this->load->view('templates/user-footer');
        } else {

            $id = $this->input->post('id_pembayaran');
            $kd_pembayaran = $this->input->post('kd_pembayaran');
            $klien = $this->input->post('klien');
            $tempat = $this->input->post('tempat');
            $tgl_bayar = $this->input->post('tgl_bayar');
            $tgl_deliv = $this->input->post('tgl_deliv');
            $jml_beli = $this->input->post('jml_beli');
            $total = $this->input->post('total');
            $id_pembeli = $this->input->post('id_pembeli');
            $uploadImg = $_FILES['bukti_img']['name'];

            if ($uploadImg) {
                $config['allowed_types'] = 'jpg|gif|png';
                $config['max_size']      = 2048;
                $config['max_width']     = 1024;
                $config['max_height']    = 1024;
                $config['upload_path']   = './assets/img/bukti/';

                $this->load->library('upload', $config);

                if ($this->upload->do_upload('usr_image')) {
                    $oldImg = $data['user']['usr_image'];
                    if ($oldImg != 'default.jpeg') {
                        unlink(FCPATH . 'assets/img/bukti/' . $oldImg);
                    }
                    $newImg = $this->upload->data('file_name');
                    $this->db->set('usr_image', $newImg);
                } else {
                    $this->session->set_flashdata('message', '<div class="alert alert-danger" role="alert">' . $this->upload->display_errors() . '</div>');
                    redirect('user/profile');
                }
            }
            $data = [
                'id_pembayaran' => $id,
                'kd_pembayaran' => random_string('alnum', '10'),
                'klien' => $klien,
                'tempat' => $tempat,
                'tgl_bayar' => $tgl_bayar,
                'tgl_deliv' => $tgl_deliv,
                'jm_beli' => $jml_beli,
                'total' => $total,
                'id_pembeli' => $id_pembeli

            ];

            $this->db->insert('pembayaran', $data);
            $this->session->set_flashdata('message', '<div class="alert alert-success" role="alert">Please wait admin approve your post</div>');
            redirect('user/order');
        }
    }

avatar werich1
@werich1

89 Kontribusi 7 Poin

Dipost 4 tahun yang lalu

Tanggapan

Kirimin code dan gambar errornya gan silahkan di edit

udah ane submit nih gan ane edit

Belum ada Jawaban. Jadi yang pertama Jawaban

Login untuk ikut Jawaban