tidak bisa menghapus data Notice: Undefined index: id

ketika delete sembarang data, muncul pesan error notice: undefined index: id. yang ingin saya tanyakan bagaimana cara memperbaiki pesan error tersebut sehingga proses hapus data dapat berjalan sebagaimana mestinya?

ini script untuk menghapus:

 <?php
	include('../config.php');

	$id		=	$_GET['id'];
	mysqli_query($dbconnect,"delete from monota where id='$id'");


?>

tampilan errornya:

avatar smartquest92
@smartquest92

5 Kontribusi 0 Poin

Diperbarui 6 tahun yang lalu

6 Jawaban:

Variabel id nya belum kekirim tuh.

avatar zhoirudin
@zhoirudin

7 Kontribusi 1 Poin

Dipost 6 tahun yang lalu

supaya mau kekirim variabel "id"-nya, kodenya harus diubah dibagian apa?

avatar smartquest92
@smartquest92

5 Kontribusi 0 Poin

Dipost 6 tahun yang lalu

kalo mau sembunyiin error nya cukup kasih @$_GET['id']

// cara panggil nya harus : script.php?id=123
// output -> 123
$id=$_GET['id'];

avatar riyanxp
@riyanxp

70 Kontribusi 50 Poin

Dipost 6 tahun yang lalu

@riyanxp: sudah saya coba menambahkan karakter "@" didepan syntax $_GET malah error object not found, padahal posisi file dalam URL sudah benar.

script

 <?php
	include('../config.php');

	$id		=	@$_GET['id'];
	mysqli_query($dbconnect,"delete from monota where id='$id'");
?>

hasil run file hapus

posisi file :

avatar smartquest92
@smartquest92

5 Kontribusi 0 Poin

Dipost 6 tahun yang lalu

SALAH : busak.php&id=11

BENAR : busak.php?id=11

Pemanggilan url dalam $_GET harus diawali dengan '?' bukan '&'

CONTOH 1 :

busak.php?id=11

CONTOH 2 :

busak.php?id=11&nama=xx

CONTOH 3 :

busak.php?id=11&nama=riyan&kelas=15
avatar riyanxp
@riyanxp

70 Kontribusi 50 Poin

Dipost 6 tahun yang lalu

problem solved gan. maaf, saya kurang teliti dalam pemilihan karakter.. terimakasih atas bantuannya...

avatar smartquest92
@smartquest92

5 Kontribusi 0 Poin

Dipost 6 tahun yang lalu

Login untuk ikut Jawaban