I've created a PHP Script that was designed to submit a HTML form as an email when filled out and submitted. The problem is after submitting it the page is directed to the PHP script file and does not redirect to my confirmation HTML page to verify it was successful or failed. The email is received it's just the 'header' feature does not work.
<?php
// $mailto - set to the email address you want the form
// sent to, eg
// $mailto = "youremailaddress@example.com" ;
$mailto = 'youremailaddress@example.com' ;
// $email_subject - set to the Subject line of the email, eg
//$email_subject = "Feedback Form" ;
$email_subject = "Email Form - $subject" ;
// the pages to be displayed, eg
// $formurl = "http://www.example.com/feedback.html" ;
// $errorurl = "http://www.example.com/error.html" ;
// $thankyouurl = "http://www.example.com/thankyou.html" ;
$formurl = "http://myURL.com/forms/email/requests.htm" ;
$errorurl = "http://myURL.com/forms/email/error.htm" ;
$thankyouurl = "http://myURL.com/forms/email/thank_you.htm" ;
$uself = 0;
// -------------------- END OF CONFIGURABLE SECTION ---------------
$headersep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" : "\n" ;
$company = $_POST['company'] ;
$first_name = $_POST['first_name'] ;
$last_name = $_POST['last_name'] ;
$email = $_POST['email'] ;
$phone = $_POST['phone'] ;
$subject = $_POST['subject'] ;
$message = $_POST['message'] ;
$http_referrer = getenv( "HTTP_REFERER" );
if (!isset($_POST['email'])) {
header("Location:$formurl");
exit();
}
if (empty($company) || empty($first_name) || empty($last_name) || empty($email) || empty($phone) || empty($subject) || empty($message)) {
header("Location:$errorurl");
exit();
}
if (ereg( "[\r\n]", $first_name ) || ereg( "[\r\n]", $email ) ) {
header("Location:$errorurl");
exit();
}
if (get_magic_quotes_gpc()) {
$message = stripslashes( $message );
}
$messageproper =
"This message was sent from:\n" .
"$http_referrer\n" .
"------------------------------------------------------------\n" .
"Company: $company\n" .
"Name: $first_name $last_name\n" .
"Email: $email\n" .
"Phone: $phone\n" .
"------------------------- MESSAGE -------------------------\n\n" .
"Subject: $subject\n\n" .
$message .
"\n\n------------------------------------------------------------\n" ;
mail($mailto, $email_subject, $messageproper,
"From: \"$first_name $last_name\" <$email>" . $headersep . "Reply-To: \"$first_name $last_name\" <$email>" . $headersep . "X-Mailer: chfeedback.php 2.07" ) ;
header("Location: $thankyouurl");
exit();
?>