Your code is badly formed again:
<?php
if (isset($_POST['send']))
{
if (empty($message))
{
header('Location: stop_talking.html');
}
else if (isset($_SESSION['username']))
{
$fp = fopen('messages.txt', 'a', 1);
$message = htmlspecialchars($_POST['message-text']);
fwrite($fp, "$_SESSION[username]: $message " . PHP_EOL);
echo "<script>if ( window.history.replaceState ) {
window.history.replaceState( null, null, window.location.href );
}
document.location.reload()</script>";
}; <--- Do not put semi-colons on close braces
}; <--- ditto
?>