Data tidak berubah setelah di edit

bisa gila · Aug 29, 2013
saya mau nanya, kenapa ya data saya tidak berubah ketika saya edit? padahal saat saya klik edit, ada alert data berhasil diupdate.
ini source code edit punya saya :
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Aplikasi Rute Rumah Sakit Kota Bogor</title>
</head>

<body>
<table>
<?php
include"program/koneksi.php";

$sql = mysql_query("select * from rumahsakit") or die(mysql_error());

echo"
<tr>
<td>No.</td>
<td>Nama Rumah Sakit</td>
<td>Alamat Rumah Sakit</td>
<td colspan='2' width='50'>Aksi</td>
</tr>";
while($row = mysql_fetch_array($sql)){
	echo"<tr>";
	echo"<td>".$row['id_rs']."</td>";
	echo"<td>".$row['namars']."</td>";
	echo"<td>".$row['alamatrs']."</td>";
	echo"<td>
	<a href='program/editrs.php?id_rs=$row[id_rs]'><abbr title='edit'><img src='../gambar/edit-icon.png' width='15' height='15'></abbr></a>
	<a href='program/proseshapusrs.php?id_rs=$row[id_rs]'><abbr title='hapus'><img src='../gambar/delete.png' width='15' height='15'></abbr></a>
	</td>";
	echo"</tr>";
}
?>
</table>
</body>
</html>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Lokasi</title>
</head>

<body>
<?php
include"koneksi.php";

$id_rs = $_GET['id_rs'];

$apdet = mysql_query("select * from rumahsakit where id_rs='$id_rs'") or die(mysql_error());
$edit = mysql_fetch_array($apdet);
?>
<table>
<form method="post" action="proseseditrs.php?id_rs=<?php $id_rs ?>">
<tr>
<td>Nama RS</td>
<td align="center"><b>:</b></td>
<td><input type="text" name="namars" value="<?php echo $edit['namars'] ?>"></td>
</tr>
<tr>
<td>Alamat RS</td>
<td align="center"><b>:</b></td>
<td><textarea name="alamatrs"><?php echo $edit['alamatrs'] ?></textarea></td>
</tr>
<tr>
<td></td>
<td></td>
<td colspan="2">
<input type="submit" value="edit">
<input type="reset" value="cancel">
</td>
</tr>
</form>
</table>
</body>
</html>
<?php
include"koneksi.php";

$id_rs = $_POST['id_rs'];
$namars = $_POST['namars'];
$alamatrs = $_POST['alamatrs'];

$update = mysql_query("update rumahsakit set namars='$namars', alamatrs='$alamatrs' where id_rs='$id_rs'") or die(mysql_error());

if($update){
	echo"<script type='text/javascript'>alert('Data berhasil di update')</script>";
	echo"<script type='text/javascript'>window.location='../rumahsakit.php?menu=Rumah Sakit'</script>";
}
else{
	echo"<script type='text/javascript'>alert('Database Error')</script>";
	echo"<script type='text/javascript'>window.location='../'</script>";
}
?>
Silahkan login untuk menjawab!
0
Loading...
Fandi Akhmad · Aug 30, 2013 · 0 Suka · 0 Tidak Suka
di bagian ini salahnya..
<?php
include"koneksi.php";
 
// $id_rs = $_POST['id_rs']; jangan pakai post, karena anda memparsing lewat parameter url
$id_rs = $_GET['id_rs'];
$namars = $_POST['namars'];
$alamatrs = $_POST['alamatrs'];

// kode tidak ditampilkan
//....

?>