header("Location...");
, вам НАДО после него делать exit();
!require_once 'mysql_connect.php';
if(!empty($_GET['id']) && isset($_POST['username']) && isset($_POST['mess']))
{
$username = trim(filter_var($_POST['username'], FILTER_SANITIZE_STRING));
$mess = trim(filter_var($_POST['mess'], FILTER_SANITIZE_STRING));
if (!empty($username) && !empty($mess))
{
$sql = 'INSERT INTO comments(name, mess, article_id) VALUES(?, ?, ?)';
$query = $pdo->prepare($sql);
$query->execute([$username, $mess, $_GET['id']]);
}
header("Location: /news.php?id={$_GET['id']}");
exit();
}
header("Location: ...")
.echo()
(или аналогичное) ДО ВЫЗОВА функции header("Location: ...")
.