$kategori = isset($_POST['kategori']) ? $_POST['kategori'] : '';	  	 
		 
		 
		 
    	//Hapus berita // undefined index: mode
	
if (!empty($_REQUEST['id']) && !empty($_REQUEST['mode'])){
if ($_REQUEST['mode'] == "delete"){
$id = $_REQUEST['id'];
$result = mysql_query("DELETE FROM berita WHERE id =".$id) or die(mysql_error());
		
$confirmation = ($result) ? "Data Telah terhapus." : "Gagal menghapus data."; 
	}
	}
?>
<div align="center">
	<div style="width:700px;text-align:left;padding-top:25px;">
		<form method="get" action="<?php $_SERVER['PHP_SELF'] ?>">
		<?php
			//LOAD KATEGORI
$result = mysql_query("SELECT * FROM kategori_berita ORDER BY kategori ASC") or die(mysql_error());
		?>
Pilih Kategori Terlebih dahulu 	<select name="kategori" onchange="submit();">
										<?php
if (empty($_REQUEST['kategori'])) echo '<option value="" selected="selected">--Kategori--</option>';
while ($data=mysql_fetch_array($result)){
						?><option <?php if ($_REQUEST['kategori'] == $data['id']) echo 'selected="selected"' ?> value="<?php echo $data['id']; ?>"><?php echo $data['kategori']; ?></option>

<?php
			
									}
			?>							
								</select><br/>

<a class="topLink" href="input_berita.php?kategori=<?php echo $_REQUEST['kategori']; ?>">Berita Baru >></a>

Pilih Kategori Terlebih dahulu (Translate: choose category)

--Kategori--

Notice: Undefined index: kategori in C:\xampp\htdocs\php_template2\news_manager.php on line 99 value="0">Action

Notice: Undefined index: kategori in C:\xampp\htdocs\php_template2\news_manager.php on line 99 value="1001">News

Notice: Undefined index: kategori in C:\xampp\htdocs\php_template2\news_manager.php on line 99 value="1002">Technology

Berita Baru >> (Translate: New News >>)

There are several notices when I run category, with few errors. How to fix the errors? I thought I already define category.

Thanks before.

Recommended Answers

All 3 Replies

Use $kategori as set on line two, instead of $_REQUEST['kategori'] .

If any of your others threads helped you solve your problem, mark them as solved.

Do you mean: $kategori = $_REQUEST; ?

It only works once, the first time I enter, the next one similar error appears:
Undefined index: kategori in C:\xampp\htdocs\php_template2\news_manager.php on line 74

Also, where is the solved button? How to mark it when it is solved?

Thanks.

No, I mean replace $_REQUEST['kategori'] with $kategori in your code.

The solved button is near the reply box if I remember correctly.

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.