<html>
<head>
<title>Form</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<body>
<?php
include("db_connection.php");
// tıknak replace
function r($data)
{
return str_replace("'", "\'", $data);
}
$id = @$_GET["id"];
if ($_POST) {
$adsoyad = $_POST["adsoyad"];
$eposta = $_POST["eposta"];
$mesaj = $_POST["mesaj"];
$onay = $_POST["onay"];
$adsoyad = r($adsoyad);
$eposta = r($eposta);
$mesaj = r($mesaj);
$onay = r($onay);
$sorgu = "UPDATE mesajlar SET
yazan='$adsoyad',
eposta='$eposta',
mesaj='$mesaj',
onay='$onay'
WHERE id='$id'";
$guncelle = mysql_query($sorgu);
if ($guncelle) {
echo '<font color="red">başarıyla güncellendi</font>';
} else {
echo 'bir sorun oluştu<br />' . mysql_error();
}
} else {
$bul = mysql_query("select * from mesajlar WHERE id='$id'");
$goster = mysql_fetch_array($bul);
extract($goster);
echo '<form action="" method=post>
<table cellpadding="5" cellpadding="5">
<tr>
<td>Ad Soyad</td>
<td><input type="text" name="adsoyad" value="' . $yazan . '" ></td>
</tr>
<tr>
<td>Eposta</td>
<td><input type="text" name="eposta" value="' . $eposta . '" /></td>
</tr>
<tr>
<td>Mesaj</td>
<td><textarea row="10" cols="30" name="mesaj">' . $mesaj . '</textarea></td>
</tr>
<tr>
<td>Onay</td>
<td><select name="onay">
<option value="1"';
if ($onay == 1) {
echo ' selected';
}
echo '>Evet</option>
<option value="0"';
if ($onay == 0) {
echo ' selected';
}
echo '>Hayır</option>
</select></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Güncelle" /></td>
</tr>
</table>
</form>';
}
?>
</body>update yazımıda hatalıydı yukardaki kodlar büyük ihtimal çalışacaktır.