Why is this not working?

This is a script I have which creates a contact form on a web page. When I run this it places most of the code right on the page. Can anyone see a problem here?


<!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>
<link rel="stylesheet" type="text/css" href="style.css" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title></title>

<?php
 // YOUR EMAIL ADDRESS
 define ("MYEMAIL","[EMAIL="m7@yahoo.com"]m7@yahoo.com[/EMAIL]"); // YOU MUST ENTER YOUR EMAIL HERE
 echo MYEMAIL;
 
function show_form()
{
 $txt .= "<p align=\"center\"><b>Form to email Script</b></p>";
 $txt .= "<form name=\"f2email\" action=\"".$_SERVER['PHP_SELF']."\" method=\"POST\">";
 $txt .= "<table align=\"center\">";
 $txt .= "<tr><td>Your name:</td><td><input type=\"text\" name=\"name\" /></td></tr>";
 $txt .= "<tr><td>Your email:</td><td><input type=\"text\" name=\"email\" /></td></tr>";
 $txt .= "<tr><td>Subject:</td><td><input type=\"text\" name=\"subject\" size=\"40\" /></td></tr>";
 $txt .= "<tr><td colspan=\"2\">Your Comment:</td></tr>";
 $txt .= "<tr><td colspan=\"2\"><textarea name=\"comment\" rows=\"5\" cols=\"60\"></textarea></td></tr>";
 $txt .= "<tr><td colspan=\"2\" align=\"right\">";
 $txt .= "<button type=\"button\" name=\"send\" value=\"send\" 
    onclick=\"js_validate(document.forms['f2email']); return false;\">Send</BUTTON</td></tr>";
 // REMOVE THE FOLLOWING LINES WHEN YOU HAVE DEFINED "MYEMAIL"
 if (MYEMAIL == "")
 {
  $txt .= "<tr><td>Email To:</td><td><input type=\"text\" name=\"toemail\" /></td></tr>";
  $txt .= "<tr><td colspan=\"2\" >(You must edit the code and define \"MYEMAIL\")</td></tr>";
 }
 // ===================================================================
 $txt .= "</form>";
 return($txt);
}
function treat_submission()
{
 $name = $_POST['name']; // VISITOR'S NAME
 $email = $_POST['email']; // VISITOR'S EMAIL
 $subject = $_POST['subject'];
 $comment = $_POST['comment'];
 $my_email = MYEMAIL;
 // REMOVE THESE LINES WHEN YOU HAVE DEFINED "MYEMAIL"
 if (MYEMAIL == "")
  $my_email = $_POST['toemail'];
 else
  $my_email = MYEMAIL; 
 // =========================================================
 // THE MESSAGE
 $headers = "To: ".$my_email. "
";
 $headers .= "From: ".$email. "
";
 $msg = $name." has submitted a comment.

";
 mail($my_email, $subject, $msg, $headers);
 // MESSAGE TO VISITOR:
 $headers = "To: ".$email. "
"; // this is the email given by the visitor
 $headers .= "From: ".$my_email. "
";
 $subject = "Your message to ".$my_email;
 $msg = "Thank you for contacting us.

";
 $msg .= "We will endeavour to respond shortly.

";
 mail($email, $subject, $msg, $headers);
 $txt = "<p align=\"center\">Your email has been sent</p>";
 return($txt);
}
?>
<script type='text/javascript' language='JavaScript'>
function js_validate(theForm)
{
 // Check for name
 var name = theForm.elements['name'].value;
 if (name == "")
 {
  alert ("You must enter your name");
  theForm.elements['name'].focus();
  return true;
 }
 // Check email address
 var email = theForm.elements['email'].value;
 if (echeck(email))
 {
  alert ("You must enter a valid email address");
  theForm.elements['email'].focus();
  return true;
 }
 // Check if subject is not blank
 var sbj = theForm.elements['subject'].value;
 if (sbj == "")
 {
  alert ("You must enter a subject");
  theForm.elements['subject'].focus();
  return true;
 }
 // Check if comment is not blank
 var comt = theForm.elements['comment'].value;
 if (comt == "")
 {
  alert ("You must enter a comment");
  theForm.elements['comment'].focus();
  return true;
 }
 theForm.submit(); // form is ok, we can submit it!
}
// === EMAIL VALIDATION =================================================================================================================================
function echeck(str) 
{
 var at="@"
 var dot="."
 var lat=str.indexOf(at)
 var lstr=str.length
 var ldot=str.indexOf(dot)
 if (str.indexOf(at)==-1)
    return(true);
 if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
  return(true);
 if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
  return(true);
 if (str.indexOf(at,(lat+1))!=-1)
  return(true);
 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
  return(true);
 if (str.indexOf(dot,(lat+2))==-1)
  return(true);
 if (str.indexOf(" ")!=-1)
  return(true);
 return (false);     
}
</script>
</head>
<body class="twoColFixLtHdr">
<div id="container">
  <div id="header">
    end #header --></div>
 
  <div id="sidebar1">
    end #sidebar1 --></div>
 
  <div id="mainContent">
 <div class="navbar"><a href="">Home</a> | <a href="photos.htm">Photos</a> | <a href="contact.htm">Contact</a></div>
    <h2>Contact Information</h2>
 <div class="indent1">
 <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab" width="250" height="200" id="test1">
<param name="movie" value="slide_show.swf" /><embed src="slide_show.swf" width="250" height="200" name="test1" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" /></object>
 </div>
    <p>
 
        
 
   </p><br />
   
 <!--<form action="[EMAIL="m7@yahoo.com"]mailto:m7@yahoo.com[/EMAIL]" enctype="text/plain" method="post">
  <p><strong>Name:</strong> <input name="Name" type="text" id="Name" size="40"></p>
  <p><strong>Your E-mail:</strong> <input name="E-mail" type="text" id="E-mail" size="40"></p>
  <p><strong>Comment:</strong></p>
  <p><textarea name="Comment" cols="55" rows="5" id="Comment"></textarea></p>
  <p><input type="submit" name="Submit" value="Submit"></p>
 </form>-->
 
<?php
 if (isset($_POST['send']))
 {
  echo (treat_submission($_POST));
  unset ($_POST);
 }
 else
  echo (show_form());
?>
   
    <h2>&nbsp;</h2><!-- end #mainContent --></div>
 
 <!-- This clearing element should immediately follow the #mainContent div in order to force the #container div to contain all child floats --><br class="clearfloat" />
  <div id="footer">
      <!-- end #footer --></div>
<!-- end #container --></div>
</body>
</html>