after sending an email message through a form, i'd like to send a message like 'mail sent' or 'error, retry!' before than redirect the user to another page. here is the php code i'm using after sending the email:

```
<?php
[... send mail php code]
$mail->MsgHTML($_POST["message"]);
// this messages are not show, of course
if (!$mail->send()) {
echo '<script language="javascript">';
echo 'alert("Mailer Error: " . $mail->ErrorInfo;)';
echo '</script>';

} else {
echo '<script language="javascript">';
 echo 'alert("Message successfully sent. Thank\'s")';
echo '</script>';

}

header( 'Location: http://localhost:8888/contacts.html' ) ;

?>

```

How can i do it?