0

i have a little bit error when doing a simple registration form. My problem is the data that have input is not inserted in database.

But before i using horizontal form the data can be inserted in my database. I'm using MySQL. this is my controller :

function create(){  
$data = array(
            'nik' => $this->input->post('nik'),
            'nama' => $this->input->post('nama'),
            'tgl_lahir' =>$this->input->post('tgl_lahir'),
            'no_hp' => $this->input->post('no_hp'),
            'alamat' => $this->input->post('alamat')
        );
        $this->db->insert('profile_mitra',$data);
        redirect('admin/daftar_mitra');
    } 

and this my view called tambah_mitra.php.

View (tambah_mitra.php)

<?php $this->load->view('templates/head');?>
<?php $this->load->view('templates/sidebar');?>
<body>
  <div class="content-wrapper">
    <section class="content-header">
<section class="content">
      <div class="row">
        <!-- left column -->
        <div class="col-md-6">
          <!-- general form elements -->
          <div class="box box-primary">
            <div class="box-header with-border">
              <h3 class="box-title">Tambah Mitra</h3>

            </div>
            <!-- /.box-header -->
            <!-- form start -->
            <form role="form">
              <div class="box-body">
                <div class="form-group">
                  <?php echo validation_errors();?>
              <?php echo form_open('admin/daftar_mitra');?>
                  <label for="exampleInputEmail1">NIK</label>
                  <input type="text" class="form-control" id="nik" placeholder="NIK">
                </div>
                <div class="form-group">
                  <label for="exampleInputEmail1">Nama</label>
                  <input type="text" class="form-control" id="nama" placeholder="Nama">
                </div>
                 <div class="form-group">
                  <label for="exampleInputEmail1">Tanggal Lahir</label>
                  <input type="date" class="form-control" id="tgl_lahir" placeholder="">
                </div>
                <div class="form-group">
                  <label for="exampleInputEmail1">No.HP</label>
                  <input type="text" class="form-control" id="no_hp" placeholder="Nomor Handphone">
                </div>
                <div class="form-group">
                  <label for="exampleInputPassword1">Alamat</label>
                  <input type="alamat" class="form-control" id="alamat" placeholder="Alamat Lengkap">
                </div>
                <!-- <div class="form-group">
                  <label for="exampleInputFile">File input</label>
                  <input type="file" id="exampleInputFile">

                  <p class="help-block">Example block-level help text here.</p>
                </div> -->
                <!-- <div class="checkbox">
                  <label>
                    <input type="checkbox"> Check me out
                  </label>
                </div> -->
              </div>
              <!-- /.box-body -->

              <div class="box-footer">
                <input class="btn btn-success" type="submit" value="Simpan">
              </div>
            </form>
          </div>
        </div>
      </div>
    </section>
        </div>
        </body>
<?php $this->load->view('templates/footer');?>

1
  • Hi, and welcome to SO! What have you tried so far? Commented Dec 26, 2018 at 5:06

2 Answers 2

1

it is not inserting because you did not define name of input filed.i think this is the reason of not inserting data. please try.

<div class="form-group">
                      <label for="exampleInputEmail1">Nama</label>
                      <input type="text" class="form-control" id="nama" name="nama" placeholder="Nama">
                    </div>
Sign up to request clarification or add additional context in comments.

Comments

0

try closing your form

<?php echo form_close();?>

Also to see the errors use

<?php echo form_error('nik');  

and continue filling the (' ') in with your variables to see what the error is.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.