Postingan lainnya
Tidak bisa menyimpan saat edit data
kenapa saat edit lalu menyimpan data tapi tidak tersimpan data yang baru itu ya?
<?php
include 'header.php';
?>
<h3><span class="glyphicon glyphicon-briefcase"></span> Edit surat masuk</h3>
<a class="btn" href="surat_msk.php"><span class="glyphicon glyphicon-arrow-left"></span> Kembali, Pastikan data yang diisi lengkap sebelum disimpan</a>
<?php
$id=mysqli_real_escape_string($konek, $_GET['id']);
$sql = "select * from surat_msk where id='$id'";
$det=mysqli_query($konek, $sql)or die(mysqli_error());
while($d=mysqli_fetch_array($det)){
?>
<form action="update.php" method="post">
<table class="table">
<tr>
<td></td>
<td><input type="hidden" name="id" value="<?php echo $d['id'] ?>"></td>
</tr>
<tr>
<td>Tanggal Masuk</td>
<td><input type="date" class="form-control" name="tgl_msk" value="<?php echo $d['tgl_msk'] ?>"></td>
</tr>
<tr>
<td>No surat</td>
<td><input type="text" class="form-control" name="no_surat" value="<?php echo $d['no_surat'] ?>"></td>
</tr>
<tr>
<td>Tanggal Surat</td>
<td><input type="date" class="form-control" name="tgl_srt" value="<?php echo $d['tgl_srt'] ?>"></td>
</tr>
<tr>
<td>sifat</td>
<td>
<select class="form-control" name="id_sifat">
<?php
$sifat=mysqli_query($konek,"select * from sifat");
while($b=mysqli_fetch_array($sifat)){
?>
<option <?php if($d['id_sifat']==$b['id_sifat']){echo "selected"; } ?> value="<?php echo $b['id_sifat']; ?>"><?php echo $b['nama_sifat'] ?></option>
<?php
}
?>
</select>
</td>
</tr>
<tr>
<td>Perihal</td>
<td><input type="text" class="form-control" name="perihal" value="<?php echo $d['perihal'] ?>"></td>
</tr>
<tr>
<td>Asal</td>
<td><input type="text" class="form-control" name="asal" value="<?php echo $d['asal'] ?>"></td>
</tr>
<tr>
<td>Disposisi KADIN</td>
<td><input type="text" class="form-control" name="disposisi_kadin" value="<?php echo $d['disposisi_kadin'] ?>"></td>
</tr>
<tr>
<td>Disposisi KABID</td>
<td><input type="text" class="form-control" name="disposisi_kabid" value="<?php echo $d['disposisi_kabid'] ?>"></td>
</tr>
<tr>
<td>Disposisi KASIE</td>
<td><input type="text" class="form-control" name="disposisi_kasie" value="<?php echo $d['disposisi_kasie'] ?>"></td>
</tr>
<tr>
<td>Keterangan</td>
<td><input type="text" class="form-control" name="keterangan" value="<?php echo $d['keterangan'] ?>"></td>
</tr>
<tr>
<td>Diterima oleh</td>
<td><input type="text" class="form-control" name="diterima" value="<?php echo $d['diterima'] ?>"></td>
</tr>
<tr>
<td></td>
<td><input type="submit" class="btn btn-info" value="Simpan"></td>
</tr>
</table>
</form>
<?php
}
?>
<?php include 'footer.php'; ?>
<?php
include 'config.php';
$id=$_POST['id'];
$tgl_msk=$_POST['tgl_msk'];
$no_surat=$_POST['no_surat'];
$tgl_srt=$_POST['tgl_srt'];
$id_sifat=$_POST['id_sifat'];
$perihal=$_POST['perihal'];
$asal=$_POST['asal'];
$disposisi_kadin=$_POST['disposisi_kadin'];
$disposisi_kabid=$_POST['disposisi_kabid'];
$disposisi_kasie=$_POST['disposisi_kasie'];
$keterangan=$_POST['keterangan'];
$diterima=$_POST['diterima'];
$update = "update undangan set id='$id',
tgl_msk='$tgl_msk',
no_surat='$no_surat',
tgl_srt='$tgl_srt',
id_sifat='$id_sifat',
perihal='$perihal',
asal='$asal',
disposisi_kadin='$disposisi_kadin',
disposisi_kabid='$disposisi_kabid',
disposisi_kasie='$disposisi_kasie',
keterangan='$keterangan',
diterima='$diterima'
where id='$id'";
mysqli_query($konek, $update);
header("location:surat_msk.php");
?>
3 Jawaban:
<pre> // mungkin kurang attribut name
<input type="submit" name="submit" class="btn btn-info" value="Simpan"> </pre>
Pakai button saja mbak
<pre> <button type="submit" class="btn btn-info" value="Simpan">Simpan</button> </pre>
"id"-nya jangan ikut diupdate <pre> $update = "update undangan set tgl_msk='$tgl_msk', no_surat='$no_surat', tgl_srt='$tgl_srt', id_sifat='$id_sifat', perihal='$perihal', asal='$asal', disposisi_kadin='$disposisi_kadin', disposisi_kabid='$disposisi_kabid', disposisi_kasie='$disposisi_kasie', keterangan='$keterangan', diterima='$diterima' where id='$id'"; </pre>