// Проверка на одинаковые сообщения
$req = mysql_query("SELECT * FROM `guest` WHERE `user_id` = '$user_id' ORDER BY `time` DESC");
$res = mysql_fetch_array($req);
if ($res['text'] == $msg) {
header("location: index.php");
exit;
}