Codice PHP:
<?
if (($nome_mittente <> "") and ($messaggio <> "") and ($email_mittente <> "")) { 
// creazione query
$query "INSERT INTO commenti 
( Id_progetto , Commento , Autore , Email , Data ) 
VALUES ( '
$id','$messaggio','$nome_mittente','$email_mittente','$data'); ";                              
} else {
 
$msg "
Occorre compilare tutti i campi. [url='commento.php?Id=
$id&categoria=$categoria&Pag=$pag']Riprova[/url]";
// termina la letttura della pagina
exit();
}

// ESEGUO LA QUERY
if ( mysql_query($query) ) {
// SE LA QUERY VA A BUON FINE TORNO ALLA PRIMA PAGINA
?>
<script language='javascript'>
    location.href='prima_pagina.php';
</script>
<?
// ALTRIMENI TORNO ALLA SECONDA
} else {
?>
<script language='javascript'>
    location.href='seconda_pagina.php';
</script>
<?
}
ciao..io ho utilizzato il javascript, ma se nn esegui nessun altro output prima della query puoi utilizzare tranquillamente anche

Codice PHP:
header("Location : pagina.php");