title: php form onsubmit event loading new page with value of 0
body: <p>I am totally new to all things php but I have managed to piece meal together the below form. But for some reason that I don't understand, everytime I hit the submit button it goes to a new page with a value of 0 on it. Here is the page<br>
  <a href="http://upcycledonline.com/test/Site/myform2.php" rel="nofollow">http://upcycledonline.com/test/Site/myform2.php</a>   </p>
  
  <pre><code>&lt;?php
      if($_POST['formSubmit'] == "Submit"){
          $errorMessage = "";
  
          if(empty($_POST['formEmail'])){
              $errorMessage .= "&lt;li&gt;You forgot to enter your email&lt;/li&gt;";
          }
  
          $varEmail = ($_POST['formEmail'].mysql_real_escape_string);
  
          //$varEmail = $_POST['formEmail'];
  
          if(empty($errorMessage)){
  
              $db = mysql_connect("server","id","password");
              if(!$db)
                  die("Error connecting to MySQL database.");
              mysql_select_db("tableName" ,$db);
  
              $sql = "INSERT INTO emails(email) VALUES ('$varEmail')";
              mysql_query($sql);
  
  
              //$sql = ("INSERT INTO emails(email) VALUES ('%s')".mysql_real_escape_string($varEmail));
              //$results = mysql_query($sql);
              //$sql = "INSERT INTO emails (emails)" 
                     //. "VALUES ('{$varEmail}');
              //mysql_query($sql);
  
              // echo "Details added";
              // $_SESSION['status'] = 'success';
          }
  
          //header("Location: thankyou.html");
          exit();
      }
  
  
      function PrepSQL($value){
          // Stripslashes
          if(get_magic_quotes_gpc()){
              $value = stripslashes($value);
          }
  
          // Quote
          //this is how I should be doing the escape thing
          $value = "'" . mysql_real_escape_string($value) . "'";
  
          return($value);
      }
  ?&gt;
  </code></pre>
  
  <p>and here is the form</p>
  
  <pre><code>&lt;?php
     if(!empty($errorMessage)){
         echo("&lt;p&gt;There was an error with your form:&lt;/p&gt;\n");
         echo("&lt;ul&gt;" . $errorMessage . "&lt;/ul&gt;\n");
     }
  ?&gt;
  
  &lt;form id="emailForm" action="&lt;?php echo htmlentities($_SERVER['PHP_SELF']); ?&gt;" 
        method="post" onSubmit="alert('Thank you. Your email has been added.')"&gt;
      &lt;label for='formEmail'&gt;Sign up to be notified when we go live!&lt;/label&gt;&lt;br/&gt;
      &lt;input type="text" name="formEmail" maxlength="50" value="&lt;?=$varEmail;?&gt;" /&gt;
      &lt;input type="submit" name="formSubmit" value="Submit" /&gt;
  &lt;/form&gt;
  </code></pre>