Postingan lainnya
notice: undefined index:
selamat pagi kak..
sayaa bertanyaa tentang : saya kaan punyaaa 2 tabel didalam database misalnya 1. tabel A dan yang ke2 : tabel B . kenapa pada saay saya klik button edit di tabel A dan B untuk mencoba edit data baru kenapa malah langsung muncul ( notice: undefined index: ) dan diaa menuju ke sini souce code di bawa ini padahal saya sudah melihat di yutub cara nyaa sukses tapi pas saya praktekkan langsung tapi malah mucul ( notice: undefined index: ) ...
$koneksi ->query ("UPDATE tbl_surat_masuk SET no= '$_POST[no]', no_surat = '$_POST[no_surat]', asal_surat = '$_POST[asal_surat]', isi= '$_POST[isi]', tgl_surat = '$_POST[tgl_surat]', tgl_terima = '$_POST[tgl_terima]',tujuan= '$_POST[tujuan]', keterangan = '$_POST[keterangan]' WHERE id_surat = '$_GET[id]'");
(SOURCE CODE YANG TABEL A)
<div class="form-group">
<label for="no" class="col-sm-2 control-label">No </label>
<div class="col-sm-10">
<input type="number" class="form-control" name="no" value="<?php echo $tampil['no'] ?>">
</div>
</div>
<div class="form-group">
<label for="no_surat" class="col-sm-2 control-label">No surat</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="no_surat" value="<?php echo $tampil['no_surat'] ?>">
</div>
</div>
<div class="form-group">
<label for="asal_surat" class="col-sm-2 control-label">Asal Surat</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="asal_surat" value="<?php echo $tampil['asal_surat'] ?>">
</div>
</div>
<div class="form-group">
<label for="isi" class="col-sm-2 control-label">Isi Surat</label>
<div class="col-sm-10">
<textarea name="isi" class="form-control" ><?php echo $tampil ['isi']; ?></textarea>
</div>
</div>
<div class="form-group">
<label for="tgl_terima" class="col-sm-2 control-label">Tanggal Surat</label>
<div class="col-sm-10">
<input type="date" class="form-control" name="tgl_surat" value="<?php echo $tampil['tgl_surat'] ?>">
</div>
<div class="form-group">
<label for="tgl_terima" class="col-sm-2 control-label">Tanggal Pelaksanaan</label>
<div class="col-sm-10">
<input type="date" class="form-control" name="tgl_terima" value="<?php echo $tampil['tgl_surat'] ?>">
</div>
</div>
<div class="form-group">
<label for="tujuan" class="col-sm-2 control-label">Tempat pelaksanaan</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="tujuan" value="<?php echo $tampil['tujuan'] ?>">
</div>
</div>
<div class="form-group">
<label for="keterangan" class="col-sm-2 control-label">Keterangan</label>
<div class="col-sm-10">
<textarea name="keterangan" class="form-control" ><?php echo $tampil ['keterangan']; ?></textarea>
</div>
<br><br><br>
<center><button class="btn btn-primary" name="Ubah" type="submit">Ubah</button>
<a href="index.php?halaman=suratmasuk" class="btn btn-warning"> Kembali </a></center>
</div>
</div>
</div>
</div>
</form>
<?php
$koneksi ->query ("UPDATE tbl_surat_masuk SET no= '$_POST[no]', no_surat = '$_POST[no_surat]', asal_surat = '$_POST[asal_surat]', isi= '$_POST[isi]', tgl_surat = '$_POST[tgl_surat]', tgl_terima = '$_POST[tgl_terima]',tujuan= '$_POST[tujuan]', keterangan = '$_POST[keterangan]' WHERE id_surat = '$_GET[id]'");
echo "<script>alert('Data Berhasil Diubah');</script>";
echo "<script>Location='index.php?halaman=suratmasuk';</script>";
(SOURCE CODE TABEL B)
<div class="form-group">
<label for="no" class="col-sm-2 control-label">No </label>
<div class="col-sm-10">
<input type="number" class="form-control" name="no" value="<?php echo $tampil['no'] ?>">
</div>
</div>
<div class="form-group">
<label for="no_surat" class="col-sm-2 control-label">No surat</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="no_surat" value="<?php echo $tampil['no_surat'] ?>">
</div>
</div>
<div class="form-group">
<label for="asal_surat" class="col-sm-2 control-label">Asal Surat</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="asal_surat" value="<?php echo $tampil['asal_surat'] ?>">
</div>
</div>
<div class="form-group">
<label for="isi" class="col-sm-2 control-label">Isi Surat</label>
<div class="col-sm-10">
<textarea name="isi" class="form-control" ><?php echo $tampil ['isi']; ?></textarea>
</div>
</div>
<div class="form-group">
<label for="tgl_terima" class="col-sm-2 control-label">Tanggal Surat</label>
<div class="col-sm-10">
<input type="date" class="form-control" name="tgl_surat" value="<?php echo $tampil['tgl_surat'] ?>">
</div>
</div>
<div class="form-group">
<label for="tujuan" class="col-sm-2 control-label">Tempat pelaksanaan</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="tujuan" value="<?php echo $tampil['tujuan'] ?>">
</div>
</div>
<div class="form-group">
<label for="keterangan" class="col-sm-2 control-label">Keterangan</label>
<div class="col-sm-10">
<textarea name="keterangan" class="form-control" ><?php echo $tampil ['keterangan']; ?></textarea>
</div>
<br><br><br>
<center><button class="btn btn-primary" name="Ubah" type="submit">Ubah</button>
<a href="index.php?halaman=suratkeluar" class="btn btn-warning"> Kembali </a></center>
</div>
</div>
</div>
</div>
</form>
<?php
$koneksi ->query ("UPDATE tbl_surat_keluar SET no= '$_POST[no]', no_surat = '$_POST[no_surat]', asal_surat = '$_POST[asal_surat]', isi= '$_POST[isi]', tgl_surat = '$_POST[tgl_surat]', tujuan= '$_POST[tujuan]', keterangan = '$_POST[keterangan]' WHERE id_surat = '$_GET[id]'");
echo "<script>alert('Data Berhasil Diubah');</script>";
echo "<script>Location='index.php?halaman=suratkeluar';</script>";
2 Jawaban:
Jawaban Terpilih
form A dan B isinya sama? untuk di halaman edit didefinisikan dulu <pre> $id = $_GET['id'] </pre> dan tambahkan di halaman edit
<pre> <td><input type="hidden" name="id" value=<?php echo $_GET['id'];?>></td> </pre>
Tanggapan
okhaaay makasih sudah membantu...
<pre> <a href='https://sekolahkoding.com/comment-forum/45868/edit'>x</a> <img src='https://sekolahkoding.com/assets/images/logo.png '> s </pre>