PHP קוד:
<?Php
$id = intval($_GET['id']);
$query = mysql_query("SELECT * FROM `tbl` WHERE id='$id'") or die(mysql_error());
$row = mysql_fetch_array($query);
$id = intval($row['id']);
// אבטחה
$title = htmlspecialchars(row['title']);
$content = htmlspecialchars(row['content']);
echo <<<html
<form action="" method="post">
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td>כותרת:</td>
<td><input type="text" name="title" size="20" value="{$title}" /></td>
</tr>
<tr>
<td>תוכן:</td>
<td><textarea style="width: 80%; height:300px;">{$content}</textarea></td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="submit" value="עדכן >>" /></td>
</tr>
</table>
</form>
html;
if(isset($_POST['submit']))
{
$title = $_POST['title'];
$title = htmlspecialchars($title);
$title = mysql_real_escape_string($title);
$title = trim($title);
$content = $_POST['content'];
$content = htmlspecialchars($content);
$content = mysql_real_escape_string($content);
$content = trim($content);
$query = mysql_query("UPDATE `table_name` SET title = '$title',content = '$content' WHERE id = '$id'") or die(mysql_error());
if($query) { echo "העדכון בוצע בהצלחה.."; }
}
?>
הנה קוד קצת יותר מופרט, עם אבטחה, מה שהוספתי הוא את הצגת הערך העכשווי של הדף.
בהצלחה
