Вот файл, который добавляет комментарий. Полученная форма цепляется к уже выведенным при помощи prepend:
<?php
session_start();
include("set_params.php");
include("db.php");
include("check.php");
header("Content-type: text/html; charset=utf-8");
if ($_GET['post'] != '')
{
$id_author = (int)$my_row['id'];
$id_post = (int)$_GET['id_post'];
$comment = trim($_GET['post']);
$comment = mysql_real_escape_string($comment);
$category = 1;
$adddate = date("Y-m-d");
$query = mysql_query("INSERT INTO `comments` (id_author,id_post,comment,adddate,category)
VALUES ('$id_author','$id_post','$comment','$adddate','$category') ",$db) or die($die_error);
$query_author = mysql_query("SELECT * FROM users WHERE id='".$id_author."' LIMIT 1",$db) or die($die_error);
$author = mysql_fetch_array($query_author);
echo"<table style='margin-left:15px;'>";
echo"<tr><td colspan=3 height=10></td></tr>";
?>
<tr>
<td valign="top" width="50">
<?php
$path_to_img = "avatars/" . $author['preview'];
?>
<img src=<?=$path_to_img ?> border="0" />
</td>
<td width="10" valign="top"></td>
<td valign="top" width="475" style="font-family: tahoma, arial, verdana, sans-serif, Lucida Sans; font-size:12px; color:RGB(0,0,0); line-height:1.5;">
<span style="font-size:13px; color:RGB(0,0,0);"><b><a href="author.php?id=<?=$author[id]?>" class="comment_blog"><?php echo $author['name']." ".$author['lname']; ?></a></b></span><br>
<?php
$comment = nl2br($comment);
$comment = htmlspecialchars($comment);
echo $comment; ?><br>
<?php
$adddate = explode('-',$adddate);
if ($adddate['1'] == '01')
{
$month = "января";
}
elseif ($adddate['1'] == '02')
{
$month = "февраля";
}
elseif ($adddate['1'] == '03')
{
$month = "марта";
}
elseif ($adddate['1'] == '04')
{
$month = "апреля";
}
elseif ($adddate['1'] == '05')
{
$month = "мая";
}
elseif ($adddate['1'] == '06')
{
$month = "июня";
}
elseif ($adddate['1'] == '07')
{
$month = "июля";
}
elseif ($adddate['1'] == '08')
{
$month = "августа";
}
elseif ($adddate['1'] == '09')
{
$month = "сентября";
}
elseif ($adddate['1'] == '10')
{
$month = "октября";
}
elseif ($adddate['1'] == '11')
{
$month = "ноября";
}
elseif ($adddate['1'] == '12')
{
$month = "декабря";
}
?>
<form><input type="hidden" id="show_comments" value="1" /></form>
<span style="font-size:10px; color:RGB(100,100,100);">Опубликовано: <?php echo $adddate[2]." ".$month." ".$adddate[0]." года"; ?></span>
</td>
</tr>
</table>
<?php
}
else
{
echo 0;
}
?>