我想在数据库中存储图像并输入fild,而不是通过插入而是通过更新(通过使用UPDATE查询)。
当我想按下按钮更新时,会显示空白页面。我做错了什么,但我不知道错在哪里。有人可以帮我看看哪里出错了?
编辑slide.php
<form action="update-barangg.php" class="form-horizontal" enctype=
"multipart/form-data" id="baner_mic" method="post" name="baner_mic">
<fieldset>
<div class="control-group">
<label class="control-label" for="focusedInput">Numar</label>
<div class="controls">
<input class="input-xlarge focused" disabled name=
"kdbarang" type="disabled" value=
"<?php echo $data['id_brg']; ?>">
</div>
</div>
<div class="control-group">
<label class="control-label" for="focusedInput">firma</label>
<div class="controls">
<input class="input-xlarge focused" name="firmaa" type=
"text" value="<?php echo $data['firma']; ?>">
</div>
</div>
<div class="control-group">
<label class="control-label" for="focusedInput">Nume</label>
<div class="controls">
<input class="input-xlarge focused" name="numee" type=
"text" value="<?php echo $data['nume']; ?>">
</div>
</div>
<div class="control-group">
<label class="control-label" for=
"focusedInput">kilograme</label>
<div class="controls">
<input class="input-xlarge focused" name="kgg" type="text"
value="<?php echo $data['kg']; ?>">
</div>
</div>
<div class="control-group">
<label class="control-label" for="focusedInput">Pret
mare</label>
<div class="controls">
<input class="input-xlarge focused" name="prett" type=
"text" value="<?php echo $data['pret']; ?>"> <input class=
"input-xlarge focused" name="pret_micc" type="text" value=
"<?php echo $data['pret_mic']; ?>">
</div>
</div>
<div class="control-group">
<label class="control-label" for="focusedInput">Oferta
%</label>
<div class="controls">
<input class="input-xlarge focused" name="ofertaaa" type=
"text" value="<?php echo $data['ofertaa']; ?>">
</div>
</div>
<div class="control-group">
<label class="control-label" for="fileInput">Produs</label>
<div class="controls">
<?php echo '<img src="../slide-mic/'.$data['imagine'].'">'; ?><input class="input-file uniform_on"
id="gbarang" name="gbarang" type="file" value="">
</div>
</div>
<div class="control-group">
<label class="control-label" for="fileInput">Promotia</label>
<div class="controls">
<?php echo '<img src="../slide-mic/'.$data['promotie'].'">'; ?><br>
<input name="promotiee" type="radio" value="img0002.png">
DA<br>
<input name="promotiee" type="radio" value=""> NU
</div>
</div>
<div class="form-actions">
<button class="btn btn-primary" type="submit">Save
changes</button> <button class="btn" type=
"reset">Reset</button>
</div>
</fieldset>
</form>
更新barangg.php
<?php
//panggil file config.php untuk menghubung ke server
include('../inc/config.php');
//tempat menyimpan file
$namafolder="../slide-mic/";
//tangkap data dari form
if (!empty($_FILES["gbarang"]["tmp_name"]))
{
//tangkap data dari form
$kdBrg = $_POST['kdbarang'];
$promotied = $_POST['promotie'];
$firmaa = $_POST['firma'];
$numee = $_POST['nume'];
$kgg = $_POST['kg'];
$prett = $_POST['pret'];
$pret_micc = $_POST['pret_mic'];
$ofertaaa = $_POST['ofertaa'];
$gambar_barang = $_FILES['gbarang']['type'];
if($gambar_barang == "image/jpeg" || $gambar_barang == "image/jpg" || $gambar_barang == "image/gif" || $gambar_barang == "image/x-png")
{
$slide-mic = $namafolder . basename($_FILES['gbarang']['name']);
if (move_uploaded_file($_FILES['gbarang']['tmp_name'], $slide-mic))
{
//simpan data ke database
$query = mysql_query("UPDATE banner_mic SET promotie='$promotiee', firma='$firmaa', nume='$numee', kg='$kgg', pret='$prett', pret_mic='$pret_micc', ofertaa='$ofertaaa', imagine='$gambar_barang' where id_brg='$kdBrg'") or die(mysql_error());
if ($query)
{
header('location:slide-mic.phpmessage=update');
}
}
else
{
echo "Gambar gagal dikirim";
}
}
else
{
echo "Jenis gambar yang anda kirim salah. Harus .jpg .gif .png";
}
}
else {
echo "Anda belum memilih gambar";
}
?>
任何帮助将不胜感激。 谢谢。