Hello all PHP master,

I am new in PHP code and I need help for making edit page for database entry through PHP. I have 3 php script here :


data-barang.php

Code:
<?php	
	require 'header.php';

	require 'panel.php';
?>

<div id="content" class="right">
	<div id="title">
    	<div class="contenttitle">
    		<h1>Data Barang</h1>
    	</div>
    	<div class="topmenu">
    		<ul>
        		<li><a href="module/add-data-barang.php"><img class="icontopmenu left" src="image/add.png" title="Data Baru" alt="Data Baru"> Tambah Data</a></li>
        		<li><a href="module/edit-data-barang.php"><img class="icontopmenu left" src="image/edit.png" title="Edit Data" alt="Edit Data"> Edit Data</a></li>
        		<li><a href="module/delete-data-barang.php"><img class="icontopmenu left" src="image/delete.png" title="Hapus Data" alt="Hapus Data"> Hapus Data</a></li>
        	</ul>
    	</div>
    </div>
    <?php
		require 'connection.php';
	
		$per_page = 10;
	
		$result = mysql_query("SELECT barang.*, jenis_barang.* FROM barang, jenis_barang WHERE barang.id_jenis_barang = jenis_barang.id_jenis_barang");
		$total_results = mysql_num_rows($result);
		$total_pages = ceil($total_results / $per_page);

		if (isset($_GET['page']) && is_numeric($_GET['page'])) {
			$show_page=$_GET['page'];
		
			if ($show_page > 0 && $show_page <= $total_pages) {
			$start = ($show_page -1) * $per_page;
			$end = $start + $per_page; 
			}
			else {
				$start = 0;
				$end = $per_page; 
			}		
		}
		else {
			$start = 0;
			$end = $per_page; 
		}
	
		echo "<p><b>View Page:</b> ";
		for ($i = 1; $i <= $total_pages; $i++) {
			echo "<a href='view-paginated.php?page=$i'>$i</a> ";
		}
		echo "</p>";
		
		echo "<table class='tabledata'>";
		echo "<tr>
			<th>ID Barang</th>
			<th>Nama Barang</th>
			<th>ID Jenis Barang</th>
			<th>Jenis Barang</th>
			<th>Stok Barang</th>
			<th>Harga Beli</th>
			<th>Harga Jual</th>
		</tr>";

		for ($i = $start; $i < $end; $i++) {
			if ($i == $total_results) {break;}
			echo "<tr>";
			echo '<td>'. mysql_result($result, $i, 'id_barang').'</td>';
			echo '<td>'. mysql_result($result, $i, 'nama_barang').'</td>';
			echo '<td>'. mysql_result($result, $i, 'id_jenis_barang').'</td>';
			echo '<td>'. mysql_result($result, $i, 'nama_jenis_barang').'</td>';
			echo '<td>'. mysql_result($result, $i, 'stok_barang').'</td>';
			echo '<td>'. mysql_result($result, $i, 'harga_beli').'</td>';
			echo '<td>'. mysql_result($result, $i, 'harga_jual').'</td>';
			echo '<td><a href="edit-data-barang.php?id_barang='. mysql_result($result, $i, 'id_barang'). '">Edit</a></td>';
			echo '<td><a href="delete-data-barang.php?id_barang='. mysql_result($result, $i, 'id_barang'). '">Delete</a></td>';
			
			echo "</tr>";
		}
		echo "</table>"; 
	?>
</div>
<div class="clear"></div>
    
<?php
	require 'footer.php';
?>

add-data-barang.php

Code:
<div>
	<h2>Tambah Data Barang</h2>
	<form class="formdata" action="" method="post">
		<fieldset>
			<p><label>ID Barang</label>: <input type="text" name="idbarang" value="" /></p>
            <p><label>Nama Barang</label>: <input type="text" name="namabarang" value="" /></p>
			<p><label>ID Jenis Barang</label>: <input type="text" name="idjenisbarang" value="" /></p>
			<p><label>Stok Barang</label>: <input type="text" name="stokbarang" value="" /></p>
            <p><label>Harga Beli</label>: <input type="text" name="hargabeli" value="" /></p>
            <p><label>Harga Jual</label>: <input type="text" name="hargajual" value="" /></p>
			<p><input type="submit" name="submit" value="Submit"></p>
		</fieldset>
	</form> 
</div>
<?php 
	require ('../connection.php');
	
	if (isset($_POST['submit'])) {
		$idbarang = mysql_real_escape_string(htmlspecialchars($_POST['idbarang']));
		$namabarang = mysql_real_escape_string(htmlspecialchars($_POST['namabarang']));
		$idjenisbarang = mysql_real_escape_string(htmlspecialchars($_POST['idjenisbarang']));
		$stokbarang = mysql_real_escape_string(htmlspecialchars($_POST['stokbarang']));
		$hargabeli = mysql_real_escape_string(htmlspecialchars($_POST['hargabeli']));
		$hargajual = mysql_real_escape_string(htmlspecialchars($_POST['hargajual']));
		
		if ($idbarang==''|| $namabarang==''|| $idjenisbarang==''|| $stokbarang==''|| $hargabeli==''|| $hargajual=='') {
			$error='ERROR: Please fill in all required fields!';
		}
		else {
			mysql_query("INSERT barang SET id_barang='$idbarang', nama_barang='$namabarang', id_jenis_barang='$idjenisbarang', stok_barang='$stokbarang', harga_beli='$hargabeli', harga_jual='$hargajual'")
			or die(mysql_error());
			
			header("Location: ../data-barang.php"); 
		}
	}
?>

edit-data-barang.php

Code:
<div>
	<h2>Edit Data Barang</h2>
	<form class="formdata" action="" method="post">
		<fieldset>
			<p><label>ID Barang</label>: <input type="text" name="idbarang" value="<?php echo $idbarang; ?>" /></p>
            <p><label>Nama Barang</label>: <input type="text" name="namabarang" value="<?php echo $namabarang; ?>" /></p>
			<p><label>ID Jenis Barang</label>: <input type="text" name="idjenisbarang" value="<?php echo $idjenisbarang; ?>" /></p>
			<p><label>Stok Barang</label>: <input type="text" name="stokbarang" value="<?php echo $stokbarang; ?>" /></p>
            <p><label>Harga Beli</label>: <input type="text" name="hargabeli" value="<?php echo $hargabeli; ?>" /></p>
            <p><label>Harga Jual</label>: <input type="text" name="hargajual" value="<?php echo $hargajual; ?>" /></p>
			<p><input type="submit" name="submit" value="Submit"></p>
		</fieldset>
	</form> 
</div>
<?php
	require ('../connection.php');
	
	if (isset($_POST['submit'])) {
		if (is_numeric($_POST['id_barang'])) {
			$idbarang = mysql_real_escape_string(htmlspecialchars($_POST['idbarang']));
			$namabarang = mysql_real_escape_string(htmlspecialchars($_POST['namabarang']));
			$idjenisbarang = mysql_real_escape_string(htmlspecialchars($_POST['idjenisbarang']));
			$stokbarang = mysql_real_escape_string(htmlspecialchars($_POST['stokbarang']));
			$hargabeli = mysql_real_escape_string(htmlspecialchars($_POST['hargabeli']));
			$hargajual = mysql_real_escape_string(htmlspecialchars($_POST['hargajual']));
			
			if ($idbarang == ''|| $namabarang == ''|| $idjenisbarang == ''|| $stokbarang == ''|| $hargabeli == ''|| $hargajual == '') {
				$error = 'ERROR: Please fill in all required fields!';
			}
			else {
				mysql_query("UPDATE barang SET id_barang='$idbarang', nama_barang='$namabarang', id_jenis_barang='$idjenisbarang, stok_barang='$stokbarang', harga_beli='$hargabeli, harga_jual='$hargajual WHERE id_barang='$id'")
				or die(mysql_error()); 
				header("Location: ../data-barang.php");
			}
		}
 		else {
			echo 'Error!';
		}
	}
	else {
		if (isset($_GET['id_barang'])) {
			$id = $_GET['id_barang'];
			$result = mysql_query("SELECT * FROM barang WHERE id_barang=$id")
			or die(mysql_error());
			$row = mysql_fetch_array($result);
			
			if($row) {
				$idbarang = $row['id_barang'];
				$namabarang = $row['nama_barang'];
				$idjenisbarang = $row['id_jenis_barang'];
				$stokbarang = $row['stok_barang'];
				$hargabeli = $row['harga_beli'];
				$hargajual = $row['harga_jual'];
			}
			else {
				echo "No results!";
			}
		}
		else {
			echo 'Error!';
		}
	}
?>

The add-data-barang.php has been worked normally. But when I click "edit button" in mysql database list, I got an error message :

Code:
Object not found!

The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error.

If you think this is a server error, please contact the webmaster.
Error 404
localhost
Apache/2.4.7 (Win32) OpenSSL/1.0.1e PHP/5.5.9
Also I haven't test my edit-data-barang.php. Any help would be appreciate. Thanks in advance..