Jual Beli Produk Digital - Cepat, Aman, Dan Terpercaya Sejak 2012 (Ada 70698 Members, 832 Products, 4745 Topic, 13114 Comments)

Codeigniter-ID pada id_ tidak ikut ke save

Dibuat
Login Terakhir 1 Tahun lalu,
Telah Dilihat 1959 Kali
indrianto adi Mengatakan : Sultan Account
ASK ci
saya punya kendala ID pada id_ tidak ikut kesave tapi data form yang lainnya kesave ke db. berikut adalah tampilan form saya.
tampilan view
https://pastebin.com/UhUhvRbW
tampilan controller
https://pastebin.com/5gf0pkdR
tampilan model
https://pastebin.com/bHaPwywx
mohon bantuannya dan bimbingannya mas/mb
terimasih
Ada 1 File Kiriman :
1. 36541.png (78 KB)

Ada 5 Jawaban

indrianto adi
commented on 10 Apr 2017 21:30:24
tampilan view
<?php 
    echo "<div class='col-md-12'>
              <div class='box box-info'>
                <div class='box-header with-border'>
                  <h3 class='box-title'>Data pesanan</h3>
                </div>
              <div class='box-body'>";
              $attributes = array('class'=>'form-horizontal','role'=>'form');
              echo form_open_multipart('Keuangan/tampil_save',$attributes); 
			  echo "<div class='col-md-12'>
                  <table class='table table-condensed table-bordered'>
					<tbody>
							
							<tr>
								<th width='120px' scope='row'>Nama Paket </th>
								<td>
									<input type='text' name='id_' class='form-control' value='$rows[nama_paket]' readonly></td>
							</tr>
							<tr>
								<th width='120px' scope='row'>Peminjaman hari </th>
								
								<td><input type='text' name='program_hari' class='form-control' value='$rows[program_hari]' readonly></td>
							</tr>
							<tr>
								<th width='250px' scope='row'>Keberangkatan tanggal </th>  

								<td><input type='text' name='keberangkatan_tanggal'  class='form-control' value='$rows[keberangkatan_tanggal]' readonly></td>
								
							</tr>
							 <tr>
								<th width='120px' scope='row'>Nama Depan</th>
								<td><input type='text' name='nama_depan' class='form-control'></td>
								<th width='120px' scope='row'>Nama Tengah</th>
								<td><input type='text' name='nama_tengah' class='form-control'></td>
							</tr>
							<tr>
								
								<th width='120px' scope='row'>Nama Belakang</th>
								<td><input type='text' name='nama_belakang' class='form-control'></td>
								<th width='120px' scope='row'>Alamat</th>
								<td><textarea type='text' name='alamat' class='form-control'></textarea></td>
							</tr>
							<tr>
								
								<th width='120px' scope='row'>Tanggal lahir</th>
								<td><input type='text' name='tgl_lahir' id='tgl_lahir' class='form-control'></td>
								<th width='120px' scope='row'>Tempat lahir lahir</th>
								<td><input type='text' name='tempat_lahir' class='form-control'></td>
							</tr>
							<tr>
								
								<th width='120px' scope='row'>No HP</th>
								<td><input type='text' name='no_hp' class='form-control'></td>
								<th width='120px' scope='row'>No tlp</th>
								<td><input type='text' name='no_tlp' class='form-control'></td>
							</tr>
							<tr>
								
								<th width='120px' scope='row'>Email</th>
								<td><input type='email' name='email' class='form-control'></td>
								<th width='120px' scope='row'>Virtual account</th>
								<td><input type='text' name='no_virtual_account' class='form-control'></td>
							</tr>
							<tr>
								
								<th width='120px' scope='row'>Tgl Peminjaman</th>
								<td><input type='email' name='tgl_issued' id='tgl_issued' class='form-control'></td>
								<th width='120px' scope='row'>Tgl expired</th>
								<td><input type='text' name='tgl_expired' id='tgl_expired' class='form-control'></td>
							</tr>
							<tr>
								
									<th width='120px' scope='row'>Nama karyawan</th>
								<td>
								
								 <select name='marketing_agent' class='form-control'>
                                <option value='0'>--pilih refrensi marketing --</option>";
								foreach ($agentcabang->result_array() as $row){
								  if ($rows['id_agent'] == $row['id_agent']){
								echo "<option value='$row[id_agent]' selected>$row[nama_agent_cabang]</option>";
								}else{
								echo "<option value='$row[id_agent]'>$row[nama_agent_cabang]</option>";
                                }
                                }
                    echo "</td></tr>
                    </tbody>
                  </table>
                </div>
              </div>
              <div class='box-footer'>
                    <button type='submit' name='submit' class='btn btn-primary'>Save</button>
                    <a href='../listbranch'><button type='button' class='btn btn-default pull-right'>Cancel</button></a>
                    
                  </div>
            </div>";

controllers

	function tampil_save(){
		cek_session_admin();
		$id = $this->uri->segment(3);
		if (isset($_POST['submit'])){
		
			$this->model_main->updatedata();
			$this->id_ = $this->session->userdata('id_');
			//$data['rows'] = $this->model_main->tampil_save($id)->row_array();
			$this->session->set_flashdata("pesan", "<div class=\"col-md-12\"><div class=\"alert alert-success\" id=\"alert\">Data berhasil diupdate!! </div></div>");
            
            redirect('Keuangan/tampil_save');
		}else{
			$data['rows'] = $this->model_main->tampil_save($id)->row_array();

			$data['agentcabang'] = $this->model_main->joincabang();
			$this->session->set_flashdata("pesan", "<div class=\"col-md-12\"><div class=\"alert alert-danger\" id=\"alert\">Gagal!!</div></div>");
            
			$this->template->load('Cpanelweb/template','Cpanelweb/mod_cabang/view_tampil_save',$data);
		}
	}

model
function updatedata(){
    
        $datadb = array('id_'=>$this->db->escape_str(trim($this->input->post('id_paket'))),
                        'nama_depan'=>$this->db->escape_str(trim($this->input->post('nama_depan'))),
                        'nama_tengah'=>$this->db->escape_str(trim($this->input->post('nama_tengah'))),
                        'nama_belakang'=>$this->db->escape_str(trim($this->input->post('nama_belakang'))),
                        'alamat'=>$this->db->escape_str(trim($this->input->post('alamat'))),
                        'tgl_lahir'=>$this->db->escape_str(trim($this->input->post('tgl_lahir'))), 
                        'tempat_lahir'=>$this->db->escape_str(trim($this->input->post('tempat_lahir'))),
                        'email'=>$this->db->escape_str(trim($this->input->post('email'))),
                        'no_hp'=>$this->db->escape_str(trim($this->input->post('no_hp'))),
                        'no_telp'=>$this->db->escape_str(trim($this->input->post('no_telp'))),
                        'no_virtual_account'=>$this->db->escape_str(trim($this->input->post('no_virtual_account')))
                        //'id'=>$this->db->escape_str($this->input->post('nama_bank'))
                       );
		//$this->db->where('id_',$this->input->get('id_'));
		$this->db->insert('tbl_customer',$datadb);
	
    }



PHPMU.COM Support
commented on 10 Apr 2017 21:36:26
Assalam, Coba cek baris ini mas : 
Models : $datadb = array('id_'=>$this->db->escape_str(trim($this->input->post('id_paket'))),
Views : <input type='text' name='id_' class='form-control' value='$rows[nama_paket]' readonly></td>

data yang dikirmkan dengan name "id_", dan di model diterima "id_paket"
juga pada inputan data yang dikirimkan bukan berupa id sepertinya, karena saya lihat di atas $rows[nama_paket],.
coba share tablenya juga sekalian mas biar lebih jelas,.. :)
indrianto adi
commented on 10 Apr 2017 21:44:12
sudah saya ganti tapi tetap gak bisa mas.. ini mas screenshootannya
Terdapat 2 File dilampirkan :
1. 365411.png (236 KB)
2. asada.png (170 KB)
indrianto adi
commented on 10 Apr 2017 21:45:18
soalnya proses pertamanya.. kita klik data sesuai idnya mas kemudian menampilkan seperti gambar diatas dan id_ tidak ikut ke save
PHPMU.COM Support
commented on 10 Apr 2017 22:12:14
$rows[nama_paket] paket ini yang bermasalah mas, itu datanya dari mana,..
saya lihat dari table gak ada, dan biasanya nama paket isinya huruf/text, 
sedangkan yang jadi penampung di tbl_customer type datanya int(), jadinya gak akan mau datanya tersimpan disana,..
seharusnya ambil $rows[id_paket] saja, atau tambahkan 1 inputan lagi dengan type hidden untuk menampung id_paket,..
Maaf, Untuk Memberikan Komentar Anda Harus Login !!!

Online