Notice: Undefined index: ID in C:\xampp\htdocs\tugas\phpdb\ubahsimpan.php on line 10
im tired ,,,
how i can fix that?

My ubahdata.php

 <html> <body> <?php
$koneksi=mysqli_connect("localhost","root","") or die ("Koneksi Gagal".mysqli_error());
    mysqli_select_db($koneksi,"buku") or die ("Database gagal dibuka".mysqli_error());
    //Mejalankan Querry
    $sql="select * from anggota where id_anggota='$ID'";
    $qry=mysqli_query($koneksi, $sql) or die ("Querry gagal".mysqli_error());
    else {
?> <form action="ubahsimpan.php" method="POST" name="form1" target="self"> <table width="350" border="1"> <tr> <td colspan="2">Ubah Data Anggota </td> </tr> <tr> <td width="103">ID Anggota</td> <td width="222"> <input name="ID" type="text" size="30" maxlength="35" value="<?php echo $data['id_anggota'];?>" disabled /> </td> </tr> <tr> <td> Nama </td> <td> <input name="TxtNama" type="text"  size="30"  value="<?php echo $data['nm_anggota'];?>" maxlength="35"/> </td> </tr> <tr> <td>Alamat</td> <td> <input name="TxtAlamat" type="text"  size="30" value="<?php echo $data['alamat'];?>" maxlength="60" /> </td> </tr> <tr> <td>Jenis Kelamin</td> <td><label> <input name="RbKelamin" type="radio" value="P" checked>
                <input name="RbKelamin" type="radio" value="W" checked>
</label></td> </tr> <tr> <td> </td> <td><input type="submit" name="Submit" value="simpan" /> </td> </tr> </table> </form> </body> </html>

My ubahsimpan.php

<html> <body> <?php
    or die("Gagal konek server".mysqli_error());

    or die("Database gagal dibuka".mysqli_error());
$sql="update anggota set nm_anggota='$TxtNama',
alamat='$TxtAlamat',kelamin='$RbKelamin' where id_anggota='$ID'";
$qry=mysqli_query($koneksi, $sql)or die("Gagal Query ubah:".mysqli_error());
echo "Data berhasil diubah";
include "ubahtampil.php";
}?> </body> </html>

You use $_GET['ID'] while your form uses method="POST"

commented: Will still err as OP uses $ID in string without dots - "WHERE id_anggota = '".$ID."'" with proper apostrophes +14
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.