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());
if($koneksi){
    mysqli_select_db($koneksi,"buku") or die ("Database gagal dibuka".mysqli_error());
    $ID=$_GET['ID'];
    //Mejalankan Querry
    $sql="select * from anggota where id_anggota='$ID'";
    $qry=mysqli_query($koneksi, $sql) or die ("Querry gagal".mysqli_error());
    $data=mysqli_fetch_array($qry);
    $ID=$data['id_anggota'];
    $nama=$data['nm_anggota'];
    $alamat=$data['alamat'];
    if($data['kelamin']=="P"){
    $cekp="checked";
    $cekw="";}
    else {
    $cekp="";
    $cekw="checked";}
    }
?> <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>
                Pria
                <input name="RbKelamin" type="radio" value="W" checked>
                Wanita
</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
    $koneksi=mysqli_connect("localhost","root","")
    or die("Gagal konek server".mysqli_error());

    if($koneksi){
    mysqli_select_db($koneksi,"buku")
    or die("Database gagal dibuka".mysqli_error());
    $ID=$_POST['ID'];
    $TxtNama=$_POST['TxtNama'];
    $TxtAlamat=$_POST['TxtAlamat'];
    $RbKelamin=$_POST['RbKelamin'];
$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 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.