hello! i need some help. i want user key in their information for first time and they can update their informtaion everytime they want. my problem is user key in their information for first time, it work. but when for second time it does not work (it means update their information). for information first time user not key in all the form. so they will key in for next time. below is my coding. ahli_kemasRumah.php <form id="form1" method="post" action="ahli_kemasRumahDB.php"> <table width="779" border="0" align="center" bgcolor="#FFFFFF"> <tr> <td bgcolor="#003366"><span class="style1">* Maklumat Peribadi</span></td> </tr> </table> <table width="779" border="0" align="center" bgcolor="#FFFFFF"> <tr> <?php $db = mysql_connect("localhost","root") or die ("Could Not Connect to Server" . mysql_error()); /* select database */ mysql_select_db("ppk4a", $db) or die ("Could Not Connect to Server" . mysql_error()); $kp = $_SESSION['kp']; $result = mysql_query("SELECT * from penduduk WHERE penduduk_kp='$kp'"); $matched = mysql_fetch_array($result); echo '<td width="380">Nama</td>'; echo '<td width="8">:</td>'; echo '<td width="369"><label>'; echo '<input type="text" name="nama" id="nama" size="60" value="'.$matched['nama'].'" DISABLED />'; ?> </label></td> </tr> <tr> <?php echo '<td>Kad pengenalan</td>'; echo '<td>:</td>'; echo '<td><input type="text" name="kp" id="kp" size="60" value="'.$matched['penduduk_kp'].'" DISABLED /></td>'; mysql_close($db); ?> </tr> <tr> <td>Nombor rumah</td> <td>:</td> <td><?php $db = mysql_connect("localhost","root") or die ("Could Not Connect to Server" . mysql_error()); /* select database */ mysql_select_db("ppk4a", $db) or die ("Could Not Connect to Server" . mysql_error()); $kp = $_SESSION['kp']; $result = mysql_query("SELECT * from pemilik WHERE penduduk_kp='$kp'"); $matched = mysql_fetch_array($result); echo '<input type="text" name="rumah" id="rumah" size="60" value="'.$matched['no_rumah'].'"/></td>'; ?> </tr> <tr> <td>Tangga</td> <td>:</td> <td><?php echo '<input type="text" name="tangga" id="tangga" size="60" value="'.$matched['tangga'].'"/></td>'; mysql_close($db); ?> </tr> <tr> <td>Telefon rumah</td> <td>:</td> <td><?php $db = mysql_connect("localhost","root") or die ("Could Not Connect to Server" . mysql_error()); /* select database */ mysql_select_db("ppk4a", $db) or die ("Could Not Connect to Server" . mysql_error()); $kp = $_SESSION['kp']; $result = mysql_query("SELECT * from penduduk WHERE penduduk_kp='$kp'"); $matched = mysql_fetch_array($result); echo '<input type="text" name="telRumah" id="telRumah" size="60" value="'.$matched['tel_rmh'].'"/></td>'; ?> </tr> <tr> <td>Telefon bimbit</td> <td>:</td> <td><?php echo '<input type="text" name="telHP" id="telHP" size="60" value="'.$matched['tel_hp'].'"/></td>'; ?> </tr> <tr> <td>Status perkahwinan</td> <td>:</td> <td><label> <select name="select2" id="select2"> <option value="bujang">Bujang</option> <option value="kahwin">Kahwin</option> <option value="janda">Janda</option> <option value="duda">Duda</option> </select> </label></td> </tr> <tr> <td>Adakah anda orang kurang upaya (OKU)</td> <td>:</td> <td><label> <input type="radio" name="oku" id="oku" value="ya" /> Ya <input type="radio" name="oku" id="oku" value="tidak" checked /> Tidak</label></td> </tr> <tr> <?php echo '<td>Status ahli</td>'; echo '<td>:</td>'; echo '<td><label><input type="text" name="statusAhli" id="statusAhli" size="60" value="'.$matched['status_ahli'].'" DISABLED /></label></td>'; mysql_close($db); ?> </tr> <tr> <td>Adakah anda bekerja</td> <td>:</td> <td><label> <select name="select3" id="select3"> <option value="kerja">Bekerja</option> <option value="tidakKerja">Tidak Bekerja</option> <option value="bersara">Bersara</option> <option value="sendiri">Kerja sendiri</option> </select> </label></td> </tr> <tr> <td><div align="left">Sektor pekerjaan sekarang atau sebelum bersara</div></td> <td>:</td> <td><label> <select name="select4" id="select4"> <option value="kerajaan">Kerajaan</option> <option value="swasta">Swasta</option> <option value="sendiri">Sendiri</option> </select> </label></td> </tr> <tr> <td>Status rumah</td> <td>:</td> <td><label> <select name="select" id="select"> <option value="sendiri">Sendiri</option> <option value="sewa">Menyewa</option> </select> </label></td> </tr> </table> <p align="right"> <label> <input type="submit" name="button" id="button" value="Simpan" /> </label> </p> <label></label> <p> </p> </form> ahli_kemasRumahDB.php $kp = $_SESSION['kp']; $statusRumah = $_POST ['select']; $rumah = $_POST ['rumah']; $tangga = $_POST ['tangga']; $telRumah = $_POST ['telRumah']; $telHP = $_POST ['telHP']; $statusKahwin = $_POST ['select2']; $oku = $_POST ['oku']; $kerja = $_POST ['select3']; $sektor = $_POST ['select4']; $db = mysql_connect("localhost","root") or die ("Could Not Connect to Server" . mysql_error()); /* select database */ mysql_select_db("ppk4a", $db) or die ("Could Not Connect to Server" . mysql_error()); $query = "UPDATE penduduk SET status_kahwin='$statusKahwin', kerja='$kerjaan', alamat_kerja='$alamatPej', gaji='$gaji', tel_rmh='$telRumah', tel_hp='$telHP', tel_pej='$telPej', status_rumah='$statusRumah', boolean_kerja='$kerja', kategori_kerja='$sektor', tarikh_sara='$sara', pencen_bulan='$pencen', pndptn_akhir='$akhir', oku='$oku' WHERE penduduk_kp='$kp'"; mysql_query($query) or die(mysql_error()); if($query) { echo("<SCRIPT LANGUAGE='JavaScript'> window.alert('Maklumat anda sudah disimpan') </SCRIPT>"); echo "<script language='Javascript'>navigate('ahli_pasangan.php')</script>"; } ?>
I'm not sure what $_SESSION['kp'] and $kp contains. The problem is probably those session variables because your SQL queries has WHERE clause of $kp and 'penduduk_kp'. Check these first because your $kp value probably change and the change is probably not in the database, thus it won't do query if none of $kp is equal to 'penduduk_kp'