Well, validate2() is a javascript function, which I assumes checks for the neccesary inputs in your form. J.S. as far as I know doesnt have a built in funtion Mail() to send mail, so unless your using ajax or some other form of submission to send the variables to a PHP file to send mail, return validate2() wont send an email. what it should do is return true if all conditions are met in the form, or false if a condition fails, this will keep the form from submitting if a user puts in the wrong informaiton.
What you should do is point action="" to the script that will both send the email and store the information in the database, if action="" is empty then the file in use should peform the action
so lets take your given form and assumes it returns true
<form name="form" method="post" action="" onSubmit="return validate2();">
<input type="hidden" name="referer" value="<?=$_SERVER['HTTP_REFERER']?>">
what you can do is this
<?PHP
if (isset($_POST["referer"]))
{
/// assuming a simple insert command
$SQL="INSERT INTO `mysubmitdb` VALUES (NULL, '".$_POST["referer"]."')";
$mail_header="FROM: me@myemail.com";
$mail_to="myemail@myemail.com";
$mail_subject="This is my subject";
$mail_body="The referer is : ".$_POST["referer"];
if (!mysql_query($SQL)) echo mysql_error();
elseif (!mail($mail_to, $mail_subject, $mail_body, $mail_header)) echo "cannot send email";
else echo "submission successfull";
}
?>
in the form proccessing script, this should insert the new row and send and email using the same information