2017-01-18 79 views
-3

DATAS這是我的列表頁面無法更新PHP + MYSQL

<?php 
    error_reporting(0); 
    include ("config.php"); 
    echo" 
    <table border=1 id='kayit'>"; 
     echo"<tr> 
     <th>NO</th> 
     <th>KURULUŞ</th> 
     <th>KONU</th> 
     <th>AD-SOYAD</th> 
     <th>MEDENİ HALİ</th> 
     <th>TC</th> 
     <th>GÜNCELLE</th> 
     </tr>"; 
    $sorgu=mysql_query("select * from form"); 
    while($kayit=mysql_fetch_array($sorgu)){ 
     echo" 
     <tr> 
     <td>{$kayit[id]}</td> 
     <td>{$kayit[kurulus]}</td> 
     <td>{$kayit[konu]}</td> 
     <td>{$kayit[adsoyad]}</td> 
     <td>{$kayit[medeni]}</td> 
     <td>{$kayit[tc]}</td> 
     <td><a href='duzenle.php?id={$kayit[id]}'>GÜNCELLE</a></td> 
    </tr>";} 
    echo "</table>"; 

    ?> 

this is my edit form 

<form name="guncelle" action="guncelle.php" method="post"> 
<table cellpadding="0" cellspacing="0"> 
<tr> 
<td><input type="text" class="inputs" name="kurulus" placeholder="Kuruluş Adı" value="<?php echo $yazdir["kurulus"];?>" /></td> 
</tr> 
<tr> 
<td><input type="text" class="inputs" name="konu" placeholder="Konu" value="<?php echo $yazdir["konu"];?>" /></td> 
</tr> 
<tr> 
<td><input type="text" class="inputs" name="adsoyad" placeholder="Adı Soyadı" value="<?php echo $yazdir["adsoyad"];?>" /></td> 
</tr> 
<tr> 
<td> 
<select name="medeni" class="inputs" value="<?php echo $yazdir["medeni"];?>"> 
    <option value="" disabled selected>Medeni Hali</option> 
    <option >Evli</option> 
    <option >Bekar</option> 
</select> 
</td> 
</tr> 
<tr> 
<td><input type="text" class="inputs" name="tc" placeholder="T.C.Kimlik No" value="<?php echo $yazdir["tc"];?>" /></td> 
</tr> 
<tr> 
<td><input type="text" class="inputs" name="yas" placeholder="Yaşı" value="<?php echo $yazdir["yas"];?>" /></td> 
</tr> 
<tr> 
<td> 
<select name="mensubiyet" class="inputs" value="<?php echo $yazdir["mensubiyet"];?>"> 
    <option value="" disabled selected>Mensubiyeti</option> 
    <option value="Sivil">Sivil</option> 
    <option value="Polis">Polis</option> 
    <option value="Asker">Asker</option> 
    <option value="Yabancı Uyruklu">Yabancı Uyruklu</option> 
</select> 
</td> 
</tr> 
<tr> 
<td> 
<select name="cinsiyet" class="inputs" value="<?php echo $yazdir["cinsiyet"];?>"> 
    <option value="" disabled selected>Cinsiyeti</option> 
    <option value="Erkek">Erkek</option> 
    <option value="Kadın">Kadın</option> 
</select> 
</td> 
</tr> 
<tr> 
<tr><td><b>Adres</b></td></tr> 
<td> 
<textarea name="adres" class="inputs" rows="4" cols="50" value="<?php echo $yazdir["adres"];?>"> 

</textarea> 
</td> 
</tr> 
<tr> 
<td><input type="text" class="inputs" name="tel" placeholder="Telefon" value="<?php echo $yazdir["tel"];?>" /></td> 
</tr> 
<tr> 
<td> 
<select name="cocuk" class="inputs" value="<?php echo $yazdir["cocuk"];?>"> 
    <option value="" disabled selected>Çocuk Sayısı</option> 
    <option value="0">0</option> 
    <option value="1">1</option> 
    <option value="2">2</option> 
    <option value="3">3</option> 
    <option value="4">4</option> 
    <option value="5">5</option> 
    <option value="6">6</option> 
    <option value="7">7</option> 
    <option value="8">8</option> 
    <option value="9">9</option> 
    <option value="10">10</option> 
</select> 
</td> 
</tr> 
<tr> 
<td> 
<select name="saglik" class="inputs" value="<?php echo $yazdir["saglik"];?>"> 
    <option value="" disabled selected>Sağlık Durumu</option> 
    <option value="Yatan Hasta - Ağır">Yatan Hasta - Ağır</option> 
    <option value="Yatan Hasta - Tedavisi Sürüyor">Yatan Hasta - Tedavisi Sürüyor</option> 
    <option value="Taburcu">Taburcu</option> 
</select> 
</td> 
</tr> 
<tr> 
<td><input id="myText" class="inputs" name="thastane" placeholder="Tedavi Gördüğü Hastane" value="<?php echo $yazdir["thastane"];?>" /></td> 
</tr> 
<tr> 
<td><input id="myText1" class="inputs" name="khastane" placeholder="Kontrole Gittiği Hastane" value="<?php echo $yazdir["khastane"];?>" /></td> 
</tr> 
<tr> 
<td> 
<select class="inputs" value="<?php echo $yazdir["ibasvuru"];?>"> 
    <option value="" disabled selected>İstihdam Başvurusu</option> 
    <option value="Kendisi">Kendisi</option> 
    <option value="Eşi">Eşi</option> 
    <option value="Kızı">Kızı</option> 
    <option value="Oğlu">Oğlu</option> 
    <option value="Annesi">Annesi</option> 
    <option value="Babası">Babası</option> 
</select> 
</td> 
</tr> 
<tr> 
<td> 
<select class="inputs" value="<?php echo $yazdir["istihdam"];?>"> 
    <option value="" disabled selected>İstihdam Durumu</option> 
    <option value="Atandı">Atandı</option> 
    <option value="İşlem Devam Ediyor">İşlem Devam Ediyor</option> 
    <option value="Daha Sonra Değerlendirecek">Daha Sonra Değerlendirecek</option> 
</select> 
</td> 
</tr> 
<tr> 
<td> 
<select name="ntazminatdurumu" class="inputs" value="<?php echo $yazdir["ntazminatdurumu"];?>" > 
    <option value="" disabled selected>Nakdi Tazminat Durumu</option> 
    <option value="Ödendi">Ödendi</option> 
    <option value="İşlem Devam Ediyor">İşlem Devam Ediyor</option> 
</select> 
</td> 
</tr> 
<tr> 
<td><input type="text" class="inputs" name="ntazminat" placeholder="Nakdi Tazminat" value="<?php echo $yazdir["ntazminat"];?>" /></td> 
</tr> 
<tr> 
<td><b>İl Müdürlüğünce Sunulan Hizmetler</b></td> 
</tr> 
<tr> 
<td><input type="text" class="inputs" name="sydv" placeholder="SYDV'den Yapılan Yardımlar" value="<?php echo $yazdir["sydv"];?>" /></td> 
</tr> 
<tr> 
<td><input type="text" class="inputs" name="belediye" placeholder="Belediyeden Yapılan Yardımlar" value="<?php echo $yazdir["belediye"];?>" /></td> 
</tr> 
<tr> 
<td><input type="text" class="inputs" name="sed" placeholder="3 Kat SED Yardımı" value="<?php echo $yazdir["sed"];?>" /></td> 
</tr> 
<tr> 
<td><input type="text" class="inputs" name="cocuk1" placeholder="1. Çocuk İçin Yapılan Yardım" value="<?php echo $yazdir["cocuk1"];?>" /></td> 
</tr> 
<tr> 
<td><input type="text" class="inputs" name="cocuk2" placeholder="2. Çocuk İçin Yapılan Yardım" value="<?php echo $yazdir["cocuk2"];?>" /></td> 
</tr> 
<tr> 
<td> 
<select name="maddidurum" class="inputs" value="<?php echo $yazdir["maddidurum"];?>"> 
    <option value="" disabled selected>Maddi Durum</option> 
    <option value="İhtiyaç Sahibidir">İhtiyaç Sahibidir</option> 
    <option value="İhtiyacı Yoktur">İhtiyacı Yoktur</option> 
</select> 
</td> 
</tr> 
<tr> 
<tr><td><b>Açıklama</b></td></tr> 
<td> 
<textarea name="aciklama" class="inputs" rows="4" cols="50" value="<?php echo $yazdir["aciklama"];?>" > 

</textarea> 
</td> 
</tr> 
<tr> 
<td><input type="text" class="inputs" name="personel" placeholder="Ziyareti Gerçekleştiren Personel" value="<?php echo $yazdir["personel"];?>" /></td> 
</tr> 
<tr> 
<td><input name="id" type="hidden" value="<?php echo $id; ?>" /></td> 
</tr> 
<tr> 
<td><input type="submit" name="gonder" value="Güncelle" /></td> 
</tr> 
</table> 
</form> 

這是我的編輯頁面

<form name="guncelle" action="guncelle.php" method="post"> 
<table cellpadding="0" cellspacing="0"> 
<tr> 
<td><input type="text" class="inputs" name="kurulus" placeholder="Kuruluş Adı" value="<?php echo $yazdir["kurulus"];?>" /></td> 
</tr> 
<tr> 
<td><input type="text" class="inputs" name="konu" placeholder="Konu" value="<?php echo $yazdir["konu"];?>" /></td> 
</tr> 
<tr> 
<td><input type="text" class="inputs" name="adsoyad" placeholder="Adı Soyadı" value="<?php echo $yazdir["adsoyad"];?>" /></td> 
</tr> 
<tr> 
<td> 
<select name="medeni" class="inputs" value="<?php echo $yazdir["medeni"];?>"> 
    <option value="" disabled selected>Medeni Hali</option> 
    <option >Evli</option> 
    <option >Bekar</option> 
</select> 
</td> 
</tr> 
<tr> 
<td><input type="text" class="inputs" name="tc" placeholder="T.C.Kimlik No" value="<?php echo $yazdir["tc"];?>" /></td> 
</tr> 
<tr> 
<td><input type="text" class="inputs" name="yas" placeholder="Yaşı" value="<?php echo $yazdir["yas"];?>" /></td> 
</tr> 
<tr> 
<td> 
<select name="mensubiyet" class="inputs" value="<?php echo $yazdir["mensubiyet"];?>"> 
    <option value="" disabled selected>Mensubiyeti</option> 
    <option value="Sivil">Sivil</option> 
    <option value="Polis">Polis</option> 
    <option value="Asker">Asker</option> 
    <option value="Yabancı Uyruklu">Yabancı Uyruklu</option> 
</select> 
</td> 
</tr> 
<tr> 
<td> 
<select name="cinsiyet" class="inputs" value="<?php echo $yazdir["cinsiyet"];?>"> 
    <option value="" disabled selected>Cinsiyeti</option> 
    <option value="Erkek">Erkek</option> 
    <option value="Kadın">Kadın</option> 
</select> 
</td> 
</tr> 
<tr> 
<tr><td><b>Adres</b></td></tr> 
<td> 
<textarea name="adres" class="inputs" rows="4" cols="50" value="<?php echo $yazdir["adres"];?>"> 

</textarea> 
</td> 
</tr> 
<tr> 
<td><input type="text" class="inputs" name="tel" placeholder="Telefon" value="<?php echo $yazdir["tel"];?>" /></td> 
</tr> 
<tr> 
<td> 
<select name="cocuk" class="inputs" value="<?php echo $yazdir["cocuk"];?>"> 
    <option value="" disabled selected>Çocuk Sayısı</option> 
    <option value="0">0</option> 
    <option value="1">1</option> 
    <option value="2">2</option> 
    <option value="3">3</option> 
    <option value="4">4</option> 
    <option value="5">5</option> 
    <option value="6">6</option> 
    <option value="7">7</option> 
    <option value="8">8</option> 
    <option value="9">9</option> 
    <option value="10">10</option> 
</select> 
</td> 
</tr> 
<tr> 
<td> 
<select name="saglik" class="inputs" value="<?php echo $yazdir["saglik"];?>"> 
    <option value="" disabled selected>Sağlık Durumu</option> 
    <option value="Yatan Hasta - Ağır">Yatan Hasta - Ağır</option> 
    <option value="Yatan Hasta - Tedavisi Sürüyor">Yatan Hasta - Tedavisi Sürüyor</option> 
    <option value="Taburcu">Taburcu</option> 
</select> 
</td> 
</tr> 
<tr> 
<td><input id="myText" class="inputs" name="thastane" placeholder="Tedavi Gördüğü Hastane" value="<?php echo $yazdir["thastane"];?>" /></td> 
</tr> 
<tr> 
<td><input id="myText1" class="inputs" name="khastane" placeholder="Kontrole Gittiği Hastane" value="<?php echo $yazdir["khastane"];?>" /></td> 
</tr> 
<tr> 
<td> 
<select class="inputs" value="<?php echo $yazdir["ibasvuru"];?>"> 
    <option value="" disabled selected>İstihdam Başvurusu</option> 
    <option value="Kendisi">Kendisi</option> 
    <option value="Eşi">Eşi</option> 
    <option value="Kızı">Kızı</option> 
    <option value="Oğlu">Oğlu</option> 
    <option value="Annesi">Annesi</option> 
    <option value="Babası">Babası</option> 
</select> 
</td> 
</tr> 
<tr> 
<td> 
<select class="inputs" value="<?php echo $yazdir["istihdam"];?>"> 
    <option value="" disabled selected>İstihdam Durumu</option> 
    <option value="Atandı">Atandı</option> 
    <option value="İşlem Devam Ediyor">İşlem Devam Ediyor</option> 
    <option value="Daha Sonra Değerlendirecek">Daha Sonra Değerlendirecek</option> 
</select> 
</td> 
</tr> 
<tr> 
<td> 
<select name="ntazminatdurumu" class="inputs" value="<?php echo $yazdir["ntazminatdurumu"];?>" > 
    <option value="" disabled selected>Nakdi Tazminat Durumu</option> 
    <option value="Ödendi">Ödendi</option> 
    <option value="İşlem Devam Ediyor">İşlem Devam Ediyor</option> 
</select> 
</td> 
</tr> 
<tr> 
<td><input type="text" class="inputs" name="ntazminat" placeholder="Nakdi Tazminat" value="<?php echo $yazdir["ntazminat"];?>" /></td> 
</tr> 
<tr> 
<td><b>İl Müdürlüğünce Sunulan Hizmetler</b></td> 
</tr> 
<tr> 
<td><input type="text" class="inputs" name="sydv" placeholder="SYDV'den Yapılan Yardımlar" value="<?php echo $yazdir["sydv"];?>" /></td> 
</tr> 
<tr> 
<td><input type="text" class="inputs" name="belediye" placeholder="Belediyeden Yapılan Yardımlar" value="<?php echo $yazdir["belediye"];?>" /></td> 
</tr> 
<tr> 
<td><input type="text" class="inputs" name="sed" placeholder="3 Kat SED Yardımı" value="<?php echo $yazdir["sed"];?>" /></td> 
</tr> 
<tr> 
<td><input type="text" class="inputs" name="cocuk1" placeholder="1. Çocuk İçin Yapılan Yardım" value="<?php echo $yazdir["cocuk1"];?>" /></td> 
</tr> 
<tr> 
<td><input type="text" class="inputs" name="cocuk2" placeholder="2. Çocuk İçin Yapılan Yardım" value="<?php echo $yazdir["cocuk2"];?>" /></td> 
</tr> 
<tr> 
<td> 
<select name="maddidurum" class="inputs" value="<?php echo $yazdir["maddidurum"];?>"> 
    <option value="" disabled selected>Maddi Durum</option> 
    <option value="İhtiyaç Sahibidir">İhtiyaç Sahibidir</option> 
    <option value="İhtiyacı Yoktur">İhtiyacı Yoktur</option> 
</select> 
</td> 
</tr> 
<tr> 
<tr><td><b>Açıklama</b></td></tr> 
<td> 
<textarea name="aciklama" class="inputs" rows="4" cols="50" value="<?php echo $yazdir["aciklama"];?>" > 

</textarea> 
</td> 
</tr> 
<tr> 
<td><input type="text" class="inputs" name="personel" placeholder="Ziyareti Gerçekleştiren Personel" value="<?php echo $yazdir["personel"];?>" /></td> 
</tr> 
<tr> 
<td><input name="id" type="hidden" value="<?php echo $id; ?>" /></td> 
</tr> 
<tr> 
<td><input type="submit" name="gonder" value="Güncelle" /></td> 
</tr> 
</table> 
</form> 

,這我的更新頁面

<?php 
error_reporting(0); 
include ("config.php"); 

$id = $_POST["id"]; 
$kurulus = $_POST["kurulus"]; 
$konu = $_POST["konu"]; 
$adsoyad = $_POST["adsoyad"]; 
$medeni = $_POST["medeni"]; 
$tc = $_POST["tc"]; 
$yas = $_POST["yas"]; 
$mensubiyet = $_POST["mensubiyet"]; 
$cinsiyet = $_POST["cinsiyet"]; 
$adres = $_POST["adres"]; 
$tel = $_POST["tel"]; 
$cocuk = $_POST["cocuk"]; 
$saglik = $_POST["saglik"]; 
$thastane = $_POST["thastane"]; 
$khastane = $_POST["khastane"]; 
$ibasvuru = $_POST["ibasvuru"]; 
$ibasvuru = $_POST["istihdam"]; 
$ntazminatdurumu = $_POST["ntazminatdurumu"]; 
$ntazminat = $_POST["ntazminat"]; 
$sydv = $_POST["sydv"]; 
$belediye = $_POST["belediye"]; 
$sed = $_POST["sed"]; 
$cocuk1 = $_POST["cocuk1"]; 
$cocuk2 = $_POST["cocuk2"]; 
$maddidurum = $_POST["maddidurum"]; 
$aciklama = $_POST["aciklama"]; 
$personel = $_POST["personel"]; 
$tarihsaat = $_POST["tarihsaat"]; 

$guncelle = mysql_query("update form set kurulus='$kurulus', konu='$konu', adsoyad='$adsoyad', medeni='$medeni', tc='$tc', yas='$yas', mensubiyet='$mensubiyet', cinsiyet='$cinsiyet', adres='$adres', tel='$tel', cocuk='$cocuk', saglik='$saglik', thastane='$thastane', khastane='$khastane', ibasvuru='$ibasvuru', istihdam='$istihdam', ntazminatdurumu='$ntazminatdurumu', ntazminat='$ntazminat', sydv='$sydv', belediye='$belediye', sed='$sed', cocuk1='$cocuk1', cocuk2='$cocuk2', maddidurum='$maddidurum', aciklama='$aciklama', personel='$personel', tarihsaat='$tarihsaat' WHERE 'id=$id'"); 

if($guncelle){ 
    echo "başarılı"; 
    header("refresh:2; url=liste.php"); 
}else{ 
    echo "başarısız"; 
} 
?> 

我可以列出y數據,我可以看到我的數據編輯頁面,但我在哪裏犯錯誤更新。我按güncelle(更新)按鈕後,沒有任何變化!我很感激你發現我的錯誤。謝謝

+0

這種格式kurulus =嘗試'「。$ kurulus。」 ' –

+0

1.您應該在您的數據庫調用中添加錯誤處理,2.您應該使用非棄用的mysql api,如PDO或mysqli,3.您應該使用準備好的語句來避免sql注入,4.您有錯誤你的sql:'... WHERE'id = $ id'' – jeroen

+0

更改你的where條件WHERE id ='「。$ id。」' –

回答

0

WHERE 'ID = $身份證' 「

刪除 'ID 之前,它應該是WHERE ID =' $ ID '」

+0

kurulus ='$ kurulus'----> FALSE kurulus ='「。$ kurulus。」'----> TRUE。謝謝你們 :) – umud