Cara masukan 2 table dalam 1 form

gan ane bikin form pembayaran nah ane mau ketika form pembayaran itu 1 table baru masuk dan yang satu lg formny itu ke update beberapa bagian ane mau cuman di update bagian statusny ketika user melakukan pembayaran ini itu gimana filterny ya ?

<h1 class="h3 mb-0 text-gray-800"><?= $title; ?></h1>
<?= $this->session->flashdata('message'); ?>
<div class="row">
    <div class="col-lg">
        <?php echo form_open_multipart('home/proses_bayar'); ?>
        <div class="modal-body">
            <div class="form-group">
                <label>Nama</label>
                <input type="hidden" class="form-control" id="id_pembayaran" name="id_pembayaran">
                <input type="hidden" class="form-control" id="kd_pembayaran" name="kd_pembayaran">
                <input type="text" class="form-control" id="klien" name="klien" value="<?= $order['pelanggan']; ?>" readonly>
            </div>
            <div class="form-group">
                <label>Alamat Pengiriman</label>
                <input type="text" class="form-control" id="tempat" name="tempat" value="<?= $order['alamat'] ?>" readonly>
            </div>
            <label>Tanggal Kirim</label>
            <div class="form-group">
                <input type="date" class="form-control" id="tgl_deliv" name="tgl_deliv" value="<?= $order['tgl_kirim']; ?>" readonly>
                <input type="hidden" class="form-control" id="tgl_bayar" name="tgl_bayar">
            </div>
            <div class="form-group">
                <input type="hidden" class="form-control" id="id_barang" name="id_barang" value="<?= $order['nm_barang']; ?>">
            </div>
            <div class="form-group">
                <label>Jumlah Pembelian</label>
                <input class="form-control" id="jml_beli" name="jml_beli" value="<?= $order['jumlah']; ?>" readonly>
            </div>
            <div class="form-group">
                <label>Status</label>
                <input type="hidden" class="form-control" id="status" name="status" value="2" readonly>
            </div>
            <div class="form-group">
                <label>Total</label>
                <input type="text" class="form-control" id="total" name="total" value="<?= $order['total_harga'] ?>" readonly>
            </div>
            <div class="form-group">
                <input type="hidden" class="form-control" id="id_pembeli" name="id_pembeli" value="<?= $_SESSION['email']; ?>" readonly>

                <!--<div class=" form-group">
                    <div class="form-check">
                        <input class="form-check-input" type="checkbox" value="1" name="isActive" id="isActive" checked>
                        <label class="form-check-label" for="isActive">
                            Is it active?
                        </label>
                    </div>
            </div>-->
            </div>
            <div class="custom-file">
                <input type="file" class="custom-file-input" id="bukti_img" name="bukti_img">
                <label class="custom-file-label" for="image">Choose 1:1 image...</label>
            </div>
        </div>
        <div class="modal-footer">
            <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
            <button type="submit" class="btn btn-primary">Add</button>
            <? echo form_close(); ?>
        </div>
    </div>
</div>
</div>

</div>
</div>
</div>

ini untuk kode formny

public function proses_bayar()
    {
        $data['title'] = 'Bayar';
        $data['user'] = $this->db->get_where('user', ['email' => $this->session->userdata('email')])->row_array();

        $this->load->helper('string');

        $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_deliv');
        $tgl_deliv = $this->input->post('tgl_bayar');
        $id_barang = $this->input->post('id_barang');
        $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('bukti_img')) {
                $this->session->set_flashdata('message', '<div class="alert alert-danger" role="alert">' . $this->upload->display_errors() . '</div>');
                redirect('home/order');
            } else {
                $uploadImg = $this->upload->data('file_name');
            }
        }
        $data = [
            'id_pembayaran' => $id,
            'kd_pembayaran' => random_string('alnum', '10'),
            'klien' => $klien,
            'tempat' => $tempat,
            'tgl_deliv' => $tgl_deliv,
            'tgl_bayar' => date('Y-m-d H:i:s'),
            'id_barang' => $id_barang,
            'jml_beli' => $jml_beli,
            'total' => $total,
            'id_pembeli' => $id_pembeli,
            'bukti_img' => $uploadImg

        ];

        $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('home/order');
    }

ini proses di controllerny ane pengen si status itu jadi angka 1 ketika udah di add mohon bantuanny ane pake codeigniter

avatar werich2
@werich2

5 Kontribusi 0 Poin

Diperbarui 4 tahun yang lalu

1 Jawaban:

mohon maaf mas, coba pahamin lagi konsep crud, coba buat crud" ber kali", pahami proses pelemparan data dari ketika kita kirim dengan metode GET maupun POST, pahami query proses update, pas dia ambil id nilai setiap data, supaya mas juga logikanya jalan ,

cara ubah status contoh mau ambil $id dari session atau form $id = nilai id; if(masukin nilai perbandingan jika 1 atau 0 gapain){ $query = "query update" }else { $query = "query update" }

avatar farhanamrin
@farhanamrin

12 Kontribusi 0 Poin

Dipost 4 tahun yang lalu

Tanggapan

iya mas kalo misalkan 1 table saya ngerti tapi disitu saya melakukan insert ke table2 dan nilainy diambil dari table 1 nah saya ingin si table ke 1 ini juga bisa ke update 1 fieldny

Login untuk ikut Jawaban