When I submit the form for this script, the result is the message echoed for the "else" // If the script did not run ok.
I can't figure out what is wrong, but I think it has to do with the mail() function..
if (isset($_POST['submitted'])) {
// Check for name.
if (eregi ('^[[:alnum:]\.\' \-]{2,15}$', stripslashes(trim($_POST['name'])))) {
$n = $_POST['name'];
} else {
$n = FALSE;
echo '<p class="error">Please include your name.</p>';
}
// Check for email.
if (eregi ('^[[:alnum:][a-z0-9_\.\-]*@[a-z0-9\.\-]+\.[a-z]{2,4}$', stripslashes($_POST['email']))) {
$e = $_POST['email'];
} else {
$e = FALSE;
echo '<p class="error">Please include a valid email address.</p>';
}
if (eregi('^[[:alnum:][a-z0-9_\.\-]{2,15}$', stripslashes(trim($_POST['subject'])))) {
$s = $_POST['subject'];
} else {
$s = FALSE;
$s = 'I looked at your Portfolio...';
}
// Check for message
if (empty($_POST['message'])) {
$m = $_POST['message'];
} else {
$m = FALSE;
echo '<p class="error">You did not include your message.</p>';
}
if ($n && $e && $s && $m) { // Everythings ok.
$to = 'example@example.com';
$body = 'From: ' . $n . '\n\n';
$body .= $m;
//send me the users email
mail ($to, $_POST['subject'], $body, $_POST['email']);
// Finish the page.
echo '<p align="center"><strong>Thank you! </strong><br />Your email has been sent to <a href="mailto: example@example.com">example@example.com</a>. If your message requires a reply for any questions or comments you may have had, you should recieve a response within a week. <br />Have a nice day!</p>';
} else { // If it did not run ok.
echo '<p class="error">Your message could not sent due to a system error. I apologize for the inconvenience.</p>';
}
} // End of the main submit conditional.