SOLVED - it was a problem with my encoding: see: Fix incorrectly displayed encoding on an html document with php
I am missing something obvious here. My process.php form processor is not redirecting properly.
My code (Short version)
header(sprintf("Location: %s", $insertGoTo));
header("Location: index.html");
echo 'y u no work?', $insertGoTo;
The 'y u no work' line echos, and the page does not refresh (or throw any errors)
I took this code from another page, which works correctly. Its on the same hosting package, so there sholdnt be problems with the php version or anything link that. Any insight would be greatly appreciated.
Long Version of my code:
<?php ob_start(); ?>
<?php
$submitdate = date("F j, Y");
if (((isset($_POST["email"])) and ($_POST["email"]!="")) and ((isset($_POST["favorite-pet"])) and ($_POST["favorite-pet"]==""))) {
$name = $_POST["name"];
$name = str_replace("\r", "", $name);
$name = str_replace("\n", "", $name);
$phone = $_POST["phone"];
$phone = str_replace("\r", "", $phone);
$phone = str_replace("\n", "", $phone);
$email = $_POST["email"];
$email = str_replace("\r", "", $email);
$email = str_replace("\n", "", $email);
$comments = $_POST["comments"];
$comments = str_replace("\r", "", $comments);
$comments = str_replace("\n", "", $comments);
$message = $submitdate."\r\n\r\n";
$message .= "Name: ".$name."\r\n";
$message .= "Phone: ".$phone."\r\n";
$message .= "Email: ".$email."\r\n\r\n";
$message .= "Comments: \r\n";
$message .= $comments."\r\n\r\n";
$find = array("/bcc\:/i","/Content\-Type\:/i","/cc\:/i","/to\:/i");
$email = preg_replace($find, "", $email);
$message = preg_replace($find, "", $message);
$recipient = "example@example.com";
/* subject */
$subject = "Contact Inquiry";
$toaddress = $recipient;
$toname = $recipient;
$fromaddress = $email;
$fromname = $name;
$headers = "From: " . $name ."<" . $email .">\r\n";
$headers .= "Bcc: example@example.com\r\n";
$headers .= "Reply-To: " . $email . "\r\n";
$headers .= "Return-path: " . $email;
if(mail($recipient, $subject, stripslashes($message), $headers)) {
$insertGoTo = "sent.html";
header(sprintf("Location: %s", $insertGoTo));
} else {
echo "Message was not sent <p>";
exit;
}
} else {
$insertGoTo = "index.html";
header(sprintf("Location: %s", $insertGoTo));
header("Location: index.html");
echo 'y u no work?', $insertGoTo;
}
?>
EDIT
Ok, I changed a couple things, but still having problems
I changed the top couple lines to:
<?php ob_start();
error_reporting(E_ALL);
And the header() lines to:
$insertGoTo = "index.html";
header(sprintf("Location: %s", $insertGoTo));
exit;
I am still getting this error:
Warning: Cannot modify header information - headers already sent by (output started at .../process.php:1) in .../process.php on line 76