mercredi 8 février 2023

Can't store data using checkbox to database using codeigniter

I try to store some data using checkbox into my database, but it can't stored. Here is my code:

I try to store some data using checkbox into my database, but it can't stored. Here is my code:

I try to store some data using checkbox into my database, but it can't stored. Here is my code:

View:

<form method="post" action="<?php echo base_url().'igd/igd/input_airborne'?>">
                                <?php echo $this->session->flashdata('message_airborne');?>
                                <input type="text" class="form-control" name="KUNJUNGAN" value="<?php echo $igd->NOMOR ?>" readonly>
                                <input type="datetime-local" class="form-control" name="TANGGAL" value="<?php echo date("Y-m-d H:i:s") ?>">
                                <input type="text" class="form-control" name="OLEH" value="<?php echo $session_user->nip?>" readonly>
                                <input type="text" class="form-control" name="STATUS" value="1" readonly>

<div class="form-check">
                                    <input class="form-check-input" type="checkbox" value="" name="DESKRIPSI" id="defaultCheck1">
                                    <label class="form-check-label" for="defaultCheck1">
                                        TBC AKtif
                                    </label>
                                </div>
                                <div class="form-check">
                                    <input class="form-check-input" type="checkbox" value="" name="DESKRIPSI" id="defaultCheck2">
                                    <label class="form-check-label" for="defaultCheck2">
                                        Campak
                                    </label>
                                </div>
                                <div class="form-check">
                                    <input class="form-check-input" type="checkbox" value="" name="DESKRIPSI" id="defaultCheck1">
                                    <label class="form-check-label" for="defaultCheck1">
                                        MDR TB
                                    </label>
                                </div> 
<button class="btn btn-sm btn-success mt-1 mb-1"> Masukkan</button>
                                </form>

Controller:

 public function input_airborne(){
        $DESKRIPSI = $this->input->post('DESKRIPSI');
        $TANGGAL = $this->input->post('TANGGAL');
        $OLEH = $this->input->post('OLEH');
        $STATUS = $this->input->post('STATUS');
        $KUNJUNGAN = $this->input->post('KUNJUNGAN');

        $data = array(
            'DESKRIPSI' => $DESKRIPSI,
            'TANGGAL' => $TANGGAL,
            'OLEH' => $OLEH,
            'STATUS' => $STATUS,
            'KUNJUNGAN' => $KUNJUNGAN
        );
        $this->M_Igd->input_airborne($data, 'igd_inim_airborne');
        $this->session->set_flashdata('message_airborne','<div class="alert alert-success alert-dismissible mt-1 fade show" role="alert">
                                                Airborne berhasil dimasukkan
                                                <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                                                <span aria-hidden="true">&times;</span>
                                                </button>
                                                </div>');
        redirect($_SERVER['HTTP_REFERER']);

    }

the DESKRIPSI is field to storing my checkbox entry




Aucun commentaire:

Enregistrer un commentaire