<?php
// contact.php
if ( $_POST ['submit'] )
{
$m_name = trim($_POST[ 'MOG_name' ]);
$m_email = trim($_POST[ 'MOG_email' ]);
$m_message = trim($_POST[ 'MOG_message' ]);
// here you should test that NO required input is left EMPTY
// if it is, tell them to fill in name and email and message
// see 'else' down below
if ( !empty( $m_email ) ) {
$msg = "";
$msg .= "Contact Form Results \n \n";
$msg .= "Name: $m_name \n";
$msg .= "Email: $m_email \n";
$msg .= "Message: $m_message \n";
$recipient = "XXX";
$subject = "Submit To MOG Newsletter";
$mailheaders = "From: \t $m__name<> \n";
$mailheaders .= "Reply-To: $m__email \n \n";
$xHeaders = "From: XXX X-Mailer: PHP/" . phpversion();
mail( $recipient, $subject, $msg, $mailheaders, $xHeaders );
echo "Thank you, <b>$m_name</b> for your inquiry.<br> \n";
echo "<br> \n";
echo "<a href='index.php'>Back to index</a><br> \n";
exit; // stop, end contact.php
}
else {
// email or something was empty
echo "fill in all details, thank you!<br><br>";
}
} // end of ' if (submit) ' check
?>
<form action="<?php echo $_SERVER[ 'PHP_SELF' ] ?>" method="POST">
<table " width="70%" border="0" align="center" cellpadding="5" cellspacing="0" id="main">
<tr>
<td colspan="2">
Please Enter Your Details
And Message
</td>
</tr>
<tr>
<td align="right" width="30%">
Your Name
</td>
<td width="70%">
<input type="Text" name="MOG_name">
</td>
</tr>
<tr>
<td align="right" width="30%">
Your Email Address
</td>
<td width="70%">
<input type="Text" name="MOG_email">
</td>
</tr>
<tr>
<td align="right" width="30%">
Message
</td>
<td width="70%">
<textarea name="MOG_message" rows="10" cols="25 wrap="virtual">your msg</textarea>
</td>
</tr>
<td align="center" colspan="2">
<input type="Submit" name="submit" value="Submit">
</td>
</table>
</form>
<!-- end HTML form and wait for submit -->
this is how we usually do it
at least halojoy
now try to run this, and notice my small changes here and there
there are many things I did change!
Then complete my changes and modify,
like testing of that name, mail, message is not empty
Come back and tell us if it works - if not, we will make it WORK!
just the way you want it
Regards from sweden
/halojoy
🙂