为什么我不能将数据插入数据库

时间:2019-06-24 19:44:54

标签: php mysql

当我打开页面时,能帮我提供此代码以进行库存补给吗,代码没有执行,而是打印在页面上,这是我编写的代码

<h2>Tambah Produk </h2>

<form method="post" enctype="multipart/form-data">
    <div class="form-group">
        <label>nama</label>
        <input type="text" class="form-control" name="nama">
    </div>
    <div class="form-group">
        <label>harga (Rp)</label>
        <input type="number" class="form-control" name="harga">
    </div>
    <div class="form-group">
        <label>berat (Gr)</label>
        <input type="number" class="form-control" name="berat">
    </div>
    <div class="form-group">
        <label>deskripsi</label>
        <textarea class="form-control" name="deskripsi" rows="10"></textarea> 
    </div>
    <div class="form-group">
        <label>foto</label>
        <input type="file" class="form-control" name="foto">
    </div>
    <button class="btn btn-primary" name="save">simpan</button>
</form>
<? php
if (isset($_POST['save']))
{
    $nama = $_FILES['foto']['name'];
    $lokasi = $_FILES['foto']['tmp_name'];
    move_uploaded_file($lokasi, "../foto_produk/".$nama);
    $konek->query("insert into produk 
        (nama_produk,harga_produk,berat_produk,foto_produk ,deskripsi_produk) 
        values('$_POST[nama]','$_POST[harga]','$_POST[berat]','$_nama',$_POST[deskripsi]')");

}
?>

this is screenshot

0 个答案:

没有答案