<? if ( $_POST [ 'submit' ] AND $_POST [ 'text' ]){ . mysql_query ( "SET NAMES cp1251" ) ; . mysql_query ( "INSERT INTO caht VALUES ('',' $_POST [text] ',' $_SESSION [ login ] ', NOW ())" ); . exit( header( "location: chat.php" )) ; . } . $rew = mysql_query ( "SELECT * FROM caht ORDER BY 'time' DESC LIMIT 10" ); . mysql_query ( "SET NAMES cp1251" ); . while ( $row = mysql_fetch_assoc ( $rew )) { . echo "$row [time ] : $row [login] : $row [ text] <br>" ; . } . . echo "<form method = 'POST' action='chat.php'> . <textarea name='text'></ textarea><br><br> . <input type = 'submit' name = 'submit' value = 'Отправить'> . </form>"