ini saya lampirkan script nya
editadmin
<?php include "cek_session.php"; ?>
<?php
include "conn.php";
$id_admin = $_GET['id_admin']; //get the no which will updated
$query = "SELECT * FROM admin WHERE id_admin = $id_admin"; //get the data that will be updated
$hasil = mysql_query($query);
$data = mysql_fetch_array($hasil);
?>
<div class="post">
<h1 class="title">Edit Data Admin </h1>
<p class="meta"><em></em></p>
<div class="entry">
<p>
<form method="post" action="?page=simpanadmin">
<table>
<p style="color:red">Ket: Tanda * Harus diisi/ Tidak boleh kosong.</p>
<tr>
<td>Nama * </td><td>: <input type="text" size="30" name="nama" value="<?php echo $data['nama'];?>"/></td>
</tr>
<tr>
<td>Alamat * </td><td>: <textarea type="text" cols="20" rows="2" name="alamat" /><?php echo $data['alamat'];?></textarea></td>
</tr>
<tr>
<td>No Telepon * </td><td>: <input type="text" size="20" name="no_telp" value="<?php echo $data['no_telp'];?>"/></td>
</tr>
<tr><td><td> No Telepon harus lebih dari 7 digit</td></td></tr>
<tr>
<td>Username * </td><td>: <input type="text" size="20" name="username" value="<?php echo $data['username'];?>" readonly/></td>
</tr>
<tr>
<td>Password * </td><td>: <input type="password" size="20" name="password" value="<?php echo $data['password'];?>"/></td>
</tr>
<tr>
<input type="hidden" name="id_admin" value="<?php echo $data['id_admin']; ?>">
<td></td><td><br><br> <input type="submit" name="submit" value="Simpan" /></td>
</tr>
<tr><td><a href="?page=dataadmin"><< Back</a></td></tr>
</p>
</table>
</form>
</div>
</div>
dan ini script simpan adminnya
<?php include "conn.php";
//get the value from form update
$nama=$_POST['nama'];
$alamat=$_POST['alamat'];
$no_telp=$_POST['no_telp'];
$username=$_POST['username'];
$password=$_POST['password'];
$id_admin=$_POST['id_admin'];
//query for update data in database
if(empty($nama) || empty($alamat) || empty($no_telp) || empty($username) || empty($password)){
echo "<script language='javascript'>
alert('Data tidak boleh ada yang kosong, silahkan ulangi lagi');
document.location='?page=dataadmin';
</script>";
}else{
$query = mysql_query("UPDATE admin SET nama = '$nama', alamat = '$alamat', no_telp = '$no_telp', username = '$username', password = '$password' WHERE id_admin='$id_admin'",$koneksi) ;
echo "<script language='javascript'>
alert('Data berhasil disimpan');
document.location='?page=dataadmin';
</script>";
}
?>
script diatas sudah berhasil untuk edit data . hanya saja jika salah 1 inputan ada yang kosong, ketika disubmit lalu muncul pesan gagal, semua data2 yang ingin di edit malah jadi blank kayak mau inputin data baru . kira2 contoh script validasi untuk source diatas seperti apa ya mas ?