Mailform reply message

I am working on a contact form.
The contact form is placed on a page called contact.php and is loaded into a main page.
When someone send a email it reply’s with a thank you message.
This is done with this script

<?php
if($_POST['submitform']) {

$Naam = $HTTP_POST_VARS['Naam'];
$Email = $HTTP_POST_VARS['Email'];
$Bericht = $HTTP_POST_VARS['Bericht'];

$dcheck = explode(",",$require);
while(list($check) = each($dcheck)) {
if(!$$dcheck[$check]) {
$error .= "$dcheck[$check] ontbreekt<br>";
}
}

if ((!ereg(".+\@.+\..+", $Email)) || (!ereg("^[a-zA-Z0-9_@.-]+$", $Email))){
$error .= "Email adres is niet juist<br>";}

if($error) {
?>
          <b>FOUT MELDING</b><br>
          <?php echo $error; ?><br>
          <a href="#" onClick="history.go(-1)">Probeer opnieuw</a>
          <?php
}
else 
{

$browser = $HTTP_USER_AGENT;
$ip = $REMOTE_ADDR;

$message = "Bericht voor $recipientname:

Naam: $Naam
Email: $Email

Bericht: $Bericht

-----------------------------

Browser: $browser
User IP: $ip";


mail($recipientemail,"$subject","$Bericht","From: $Naam <$Email>");

if($autoresponse == "yes") {
$autosubject = stripslashes($autosubject);
$automessage = stripslashes($automessage);
mail($Email,"$autosubject","$automessage","From: $recipientname <$recipientemail>");
}

echo "$thanks";
}
} 
else {
?>

Problem is that all the messages are reply’d in the contact.php, this is correct but the contact.php should not open as a new blank page but should open into main.html like it opens when i click on the contact button.
Can somebody tell me how i can make this work.

Thanks in advance