product_category.php

// SIMPAN

if (isset($_REQUEST['simpan']))
	{
	$kategori = mysql_real_escape_string($_REQUEST['kategori']);
	$id = isset($_POST['id']) ? $_POST['id'] : '';	
	$id = $_REQUEST['id'];
	
	if(empty($id))
		$result = mysql_query("INSERT INTO kategori (nama_kategori) VALUE ('".$kategori."')") or die(mysql_error());
	else	
		$result = mysql_query("UPDATE kategori (nama_kategori) SET kategori = '".$kategori."') WHERE id=".$id) or die(mysql_error());
	
	$confirmation =	$result ? "Data telah tersimpan." : "Gagal menyimpan data.";
	$kategori = "";
	$id = ""; 
	}

When I execute the above code, I get this error:

Notice: Undefined index: id in C:\xampp\htdocs\Masterlink\cgoods\product_category.php on line 65 (line 8 as posted)

Why is it ? I thought I already defined $id

$_REQUEST probably doesn't exist. You don't have an 'id' parm.

Be a part of the DaniWeb community

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