First of all, I would put it all on one page and make it self posting. I haven't worked much with HTTP_REFERRER but the browser does not always provide one. You need to define a default value depending on your site to populate the URL with if no referrer is provided. I would also put a loop at the top of the page in case globals get turned off, then gather the referrer and populate the form with it. I have not tested this on my system but here is an example of how I would start to approach it:
<?php
foreach($_POST as $key => $val){
$$key=$val;
}
if(!isset($email)){ // email is required
$return=$HTTP_REFERER;
?>
<form method='post'>
<input type='hidden' name='return' value='<?php echo $return; ?>'>
//finish the table and the rest of the contact.php
<?php
}else{
//all the mail stuff here (mail.php)
echo("Your mail has been sent.<br><br>".
"<a href=\"".$return."\">go back.</a>\n");
}
?>