Postingan lainnya
Database Eror- Codeigniter PHP
Capture gghgh.PNGCapture sasss.PNG
controllers : C_data_barang.php
public function tambah_aksi()
{
$nama_barang = $this->input->post('nama_barang');
$keterangan = $this->input->post('keterangan');
$kategori = $this->input->post('kategori');
$harga = $this->input->post('harga');
$stok = $this->input->post('stok');
$gambar = $_FILES['gambar']['name'];
if ($gambar =''){}else{
$config ['upload_path'] = './img';
$config ['allowed_types'] = 'jpg/jpeg/png/gif';
$this->load->library('upload', $config);
if(!$this->upload->do_upload('gambar')){
echo "Gambar Gagal diUpload!";
}else {
$gambar = $this->upload->data('file_name');
}
$data = array(
'nama_barang' => $nama_barang,
'keterangan' => $keterangan,
'kategori' => $kategori,
'harga' => $harga,
'stok' => $stok,
'gambar' => $gambar
);
$this->model_barang->tambah_barang($data, 'barang');
redirect('c_data_barang/index');
}
}
}
1 Jawaban:
<div>name di tag inputnya di sesuaikan sama yg di ambil di $this->input->post("name_sama_dengan_di_tag_input")</div>