I don't know what is wrong with my code but it's giving me both my message and the form at the same time, before i even hit submit. My form tag is...
<FORM method="post" action="<?PHP echo $_SERVER['PHP_SELF'];?>">
<input type="submit" name="submit" value="submit">
</FORM>
Here is my php script within one page....
<?PHP
if ($_POST['submit']) {
}
$submit = $_POST['submit'] ;
$fname = $_POST['fname'] ;
$lname = $_POST['lname'] ;
$company = $_POST['company'] ;
$workphone = $_POST['workphone'] ;
$emailaddress = $_POST['emailaddress'] ;
$subject = $_POST['subject'] ;
$comments = $_POST['comments'] ;
$message = "Name: $fname $lname\nCompany: $company\nWork Phone: $workphone\nEmail: $emailaddress\nSubject: $subject\nMessage: $comments\n";
if (empty($_POST['subject'])) {
$subject="Feedback Form";
}
$sent = mail( "help@me.com",
$subject,$message, "From: $fname $lname <$email>" );
if ($sent) {
echo "<b>$fname $lname</b>, your message has been sent regarding <b>$subject</b>.
<p>A response will be sent to <b>$emailaddress</b>.";
}
else {
echo "<h2>There seems to be a problem, your mail was not sent.</h2>";
}
?>