Postingan lainnya
Column Id_customer cannot be null padahal sudah di set untuk userdata nya
selamat malam barang kali ada yang tau cara memperbaiki kasus seperti ini
Capture.PNGcontroller rental.PNGview tambah rental.PNGcontroller login.PNG
padahal sudah set untuk id_customer jadi ketika submit malah keluar error begitu,
udah cari kemana mana belum nemu hehe, terimakasih
Tanggapan
maap,,, kotak2,, ga keliatan,,,, mungkin bisa langsung di tampilkan saja scriptnya,, tanpa gambar -_-
6 Jawaban:
<div>ini ngambil nilai id customernya bagaimana kak? apakah input atau dr session? kalau misalkan input di viewnya dibagian mana ya kak id customer itu, kalau misal dr session saat settingan login id customer itu dibawa ga kak</div>
<div>sudah ketemu gan terimakasih, saya salah di bagian controller rental nya aja di bagian userdata</div>
<div>hallo mohon maaf ijin oya saya ikuti tutorial rental mobil namun jadi error dan boleh minta pentunjuk, terima kasih <br><br></div>
<div><?php <br>class Rental extends CI_Controller{<br> <br> public function tambah_rental($id)<br> {<br> $data['detail'] = $this->rental_model->ambil_id_mobil($id);<br> $this->load->view('templates_customer/header');<br> $this->load->view('customer/tambah_rental',$data);<br> $this->load->view('templates_customer/footer'); <br> }<br><br> public function tambah_rental_aksi()<br> {<br> $id_customer = $this->session->set_userdata('id_customer');<br> $id_mobil = $this->input->post('id_mobil');<br> $tanggal_rental = $this->input->post('tanggal_rental');<br> $tanggal_kembali = $this->input->post('tanggal_kembali');<br> $denda = $this->input->post('denda');<br> $harga = $this->input->post('harga');<br><br> $data = array(<br> 'id_customer' => $id_customer,<br> 'id_mobil' => $id_mobil,<br> 'tanggal_rental' => $tanggal_rental,<br> 'tanggal_kembali' => $tanggal_kembali,<br> 'denda' => $denda,<br> 'harga' => $harga,<br> 'tanggal_pengembalian' => '_',<br> 'status_rental' => 'Belum Selesai',<br> 'status_pengembalian' => 'Belum Kembali'<br> );<br><br> $this->rental_model->insert_data($data, 'transaksi');<br> $this->session->set_flashdata('pesan','<div class="alert alert-success alert-dismissible fade show" role="alert"><br> Data Transaksi Berhasil Silahkan Checkout!.<br> <button type="button" class="close" data-dismiss="alert" aria-label="Close"><br> <span aria-hidden="true">&times;</span><br> </button><br> </div>');<br> redirect('customer/data_mobil');<br> } <br>}<br><br>?><br><br></div>
<div><?php <br><br>class Rental_model extends CI_model{<br> public function get_data($table){<br> return $this->db->get($table);<br> }<br><br> public function insert_data($data,$table){<br> $this->db->insert($table,$data);<br> }<br> public function update_data($table, $date, $where){<br> $this->db->update($table,$date,$where);<br> }<br><br> public function delete_data($where,$table)<br> {<br> $this->db->where($where);<br> $this->db->delete($table);<br> }<br> public function ambil_id_mobil($id)<br> {<br> $hasil = $this->db->where('id_mobil', $id)->get('mobil');<br> if ($hasil->num_rows() > 0) {<br> return $hasil->result();<br> }else{<br> return false;<br> }<br> }<br><br> public function cek_login()<br> {<br> $username = set_value('username');<br> $password = set_value('password');<br><br> $result = $this->db<br> ->where('username',$username)<br> ->where('password',md5($username))<br> ->limit(1)<br> ->get('customer');<br><br> if ($result->num_rows() > 0) {<br> return $result->row();<br> }else{<br> return FALSE;<br> }<br> }<br><br> public function update_password($where,$data,$table)<br> {<br> $this->db->where($where);<br> $this->db->update($table,$data);<br> }<br>}<br><br>?></div>
<div><div class="container"><br> <div class="card" style="margin-top: 200px;"><br> <div class="card-header"><br> Form Rental Mobil<br> </div><br> <div class="card-body"><br> <?php foreach ($detail as $dt): ?><br> <form method="POST" action="<?php echo base_url('customer/rental/tambah_rental_aksi') ?>"><br> <br> <div class="form-group"><br> <label>Harga Sewa/Hari</label><br> <input type="hidden" name="id_mobil" value="<?php echo $dt->id_mobil ?>"><br> <input type="text" name="harga" class="form-control" value="<?php echo $dt->harga ?>" readonly><br> </div><br><br> <div class="form-group"><br> <label>Tanggal Rental</label><br> <input type="date" name="tanggal_rental" class="form-control"><br> </div><br><br> <div class="form-group"><br> <label>Tanggal Kembali</label><br> <input type="date" name="tanggal_kembali" class="form-control"><br> </div><br><br> <button type="submit" class="btn btn-warning"><i class="fa fa-car"></i> Rental</button><br> </form><br> <?php endforeach ?><br> </div><br> </div><br></div></div>