I've managed to make the name/email form with redirect function on submit to work. The only problem now is that when the redirect page loads, I get the form input on the top of it (name and email).

Anyone got the idea where did I flunk?

```
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="style.css" rel="stylesheet" type="text/css" />
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
 function submitForm() {
      var form = document.forms[0];
      if (form.name.value == '') { alert("Name?"); return; }
      if (form.email.value == '') { alert("Email?"); return; }

      apos = form.email.value.indexOf("@");
      dotpos = form.email.value.lastIndexOf(".");
      if (apos < 1 || dotpos - apos < 2) { alert("Correct email?"); return; }

      form.submit();
  }
</script>
<script src="fancybox/jquery.fancybox-1.3.1.pack.js" type="text/javascript"></script>
<link rel="stylesheet" href="fancybox/jquery.fancybox-1.3.1.css" type="text/css" media="screen"/>

<script type="text/javascript">
function PopIt() { 
    $("a#trigger").trigger('click');
    window.onbeforeunload = UnPopIt;
    return "Dont go."; 
}

function UnPopIt()  { /* nothing to return */ } 

$(document).ready(function() {
    window.onbeforeunload = PopIt;

    $("a#trigger").fancybox({
        'hideOnContentClick': false,
        'showCloseButton': false
    });

    $("a[id!=trigger]").click(function(){ window.onbeforeunload = UnPopIt; });
});
</script>

</head>
<body>

<div style="display: none;">
<a id="trigger" href="#popup">&nbsp;</a>
<div id="popup">
<div style="background-color:#ff3300;">
<form method="post" action="page2.php" name="popups" id="popups">
        <fieldset>
        <label for=name><span class="required">*</span> Name</label>
        <br />
        <input name="name" type="text" id="name" size="30" value="" /> 
        <br />
        <label for=email><span class="required">*</span> Email</label>
        <br />
        <input name="email" type="text" id="email" size="30" value="" />
        <br />
        <input type="button" value="Submit" class="btn" onclick="submitForm();">            
        </fieldset>  
        <br />
</form>
</div>        
</div>
</div>

<div id="content">Fa la la la la</div>
</div>
</body>
</html>

```

and when the visitor enters the data (in the popup window, triggered on exit), after hitting the submit button the form redirects to here;

```
<? 
if($_POST['name']!="" and $_POST['email']!=""){

$headers    = "From: Acme";
$message    = 
strtoupper($_POST['name'])."
".strtoupper($_POST['email'])."
";
echo str_replace("\n","<br />", $message);
$headers2    = "From: Acme <ceo@acme.com>\nContent-Type: text/plain; charset=UTF-8;             format=flowed\nMIME-Version: 1.0\nContent-Transfer-Encoding: 8bit\nX-Mailer: PHP\n";
$message2    = "
Hello ".($_POST['name'])."   

";

mail("ceo@acme.com", "Freebies", $message, $headers);        
mail("$_POST[email]", "Gesundheit!", $message2, $headers2);

$myFile = "free.txt";
$fh = fopen($myFile, 'a') or die("can't open file");
$stringData = "$_POST[name]*$_POST[email]*".$_SERVER['REMOTE_ADDR']."*".date("d-m-Y     H:i")."
";
fwrite($fh, $stringData);
fclose($fh);

}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="style.css" rel="stylesheet" type="text/css" />
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
setTimeout(function(){
$("div#md").fadeIn("slow", function () {
});

}, 1000);
});
</script>
</head>
<body>
<div id="top"><a href="index.html"><img src="top.png" /></a></div>
<div id="wrapper" style="height:900px;">
<div id="content">Whoo-eee</div>
</div>
</body>
</html>

```

But I dont see how or why is there the form info (name and email) shown on the top of this page2.php...