Postingan lainnya
Tidak mau update data mysql php
<!DOCTYPE html>
<html>
<head>
<title>Edit DATA MAHASISWA</title>
</head>
<body>
<h2>Edit Data Mahasiswa</h2>
<p><a href="index.php">Home</a></p>
<?php
include("koneksi.php");
$id = $_GET['id'];
$show = mysqli_query($koneksi, "SELECT*FROM biodata WHERE No = '$id'");
if (mysqli_num_rows($show) == 0) {
echo "<script>window.history.back()</script";
}
else{
$data = mysqli_fetch_assoc($show);
}
?>
<form action="edit-proses.php" method="post">
<input type="hidden" name="id" value="<?php echo $id; ?>">
<table cellpadding="5" cellspacing="0">
<tr>
<td>NIM</td>
<td>:</td>
<td><input type="text" value="<?php echo $data['NIM']; ?>" name="
NIM" required></td>
</tr>
<tr>
<td>Nama</td>
<td>:</td>
<td><input type="text" value="<?php echo $data['Nama']; ?>" name="
Nama" size="50" required></td>
</tr>
<tr>
<td>Jenis Kelamin</td>
<td>:</td>
<td>
<input type="radio" name="Jenis_Kelamin" value="Laki-Laki" required
<?php if($data['Jenis_Kelamin'] == 'Laki-Laki'){ echo 'checked';}?>>
Laki-Laki<br>
<input type="radio" name="Jenis_Kelamin" value="Perempuan" <?php if($data['Jenis_Kelamin'] == 'Perempuan'){ echo 'checked';}?>>
Perempuan
</td>
</tr>
<tr>
<td>Angkatan</td>
<td>:</td>
<td>
<select name="Angkatan" required="">
<option value="">- Pilih Angkatan - </option>
<option value="2017" <?php if($data['Angkatan'] == '2017'){ echo 'selected';}?>>2017</option>
<option value="2018" <?php if($data['Angkatan'] == '2018'){ echo 'selected';}?>>2018</option>
<option value="2019" <?php if($data['Angkatan'] == '2019'){ echo 'selected';}?>>2019</option>
<option value="2020" <?php if($data['Angkatan'] == '2020'){ echo 'selected';}?>>2020</option>
</select>
</td>
</tr>
<tr>
<td>Alamat</td>
<td>:</td>
<td>
<textarea name="Alamat" cols="30" rows="4" required ><?php echo $data['Alamat']; ?></textarea>
</td>
</tr>
<tr>
<td>No. HP</td>
<td>:</td>
<td>
<input type="text" value="<?php echo $data['No_HP']; ?>" name="No_HP" required>
</td>
</tr>
<tr>
<td colspan="2"></td>
<td>
<input type="submit" value="SIMPAN" name="simpan">
</td>
</tr>
</table>
</form>
</body>
</html>
<?php
if(isset($_POST['NIM']) && isset($_POST['Nama'] && isset($_POST['Jenis_Kelamin']) && isset($_POST['Angkatan']) && isset($_POST['Alamat']) && isset($_POST['No_HP']) && isset($_POST['simpan']))
{
include('koneksi.php');
$id = $_POST['id'];
$NIM = $data['NIM'];
$Nama = $_POST['Nama'];
$Jenis_Kelamin = $_POST['Jenis_Kelamin'];
$Angkatan = $_POST['Angkatan'];
$Alamat = $_POST['Alamat'];
$No_HP = $_POST['No_HP'];
$input = mysqli_query($koneksi,"UPDATE biodata SET NIM = '$NIM', Nama = '$Nama', Jenis_Kelamin = '$Jenis_Kelamin', Angkatan = '$Angkatan', Alamat = '$Alamat', No_HP ='$No_HP' WHERE No = '$id'") or die(mysqli_error($koneksi));
if($input){
echo "DATA BERHASIL DI UPDATE";
echo "<a href='index.php'>Back</a";
}
else{
echo "GAGAL MENGUPDATE DATA";
echo "<a href='index.php'>Back</a";
}
}
else
{
echo "Isikan Semua Data";
echo "<a href='index.php'>Back</a";
}
?>
0
Tanggapan
halo jangan hanya copy paste kodenya, biasakan melakukan "debug" dulu https://sekolahkoding.com/forum/cara-menampilkan-error-debug-di-php-1552899672 agar ada info yang lebih relevan
Belum ada Jawaban. Jadi yang pertama Jawaban
Login untuk ikut Jawaban