PHP Form Error: (Warning Cannot modify header information…)
-
Hi Guys.
Have an issue with a wordpress installation, on a contact form page.
When a user fills out a form at
http://leftofftherocks.com/contact-us
and clicks submit.They get this error:
Warning: Cannot modify header information – headers already sent by (output started at /home/lotr/public_html/wp-content/themes/lotr/contact.php:3) in /home/lotr/public_html/wp-content/themes/lotr/header.php on line 42
The form does come through to the email. But obviously i would like to remove this error.
Here is the header.php code.
<?php $browser = strpos($_SERVER['HTTP_USER_AGENT'],"iPhone"); if ($browser == true) { //echo "iphone";exit; } if(isset($_POST['fname'])) { $email_to = "[email protected]"; $email_subject = "LOTR Contact Form"; // validation expected data exists if(!isset($_POST['fname']) || !isset($_POST['subject']) || !isset($_POST['phone']) || !isset($_POST['email']) || !isset($_POST['comments']) ) { die(); } $name = $_POST['fname']; // required $organisation = $_POST['subject']; // required $phone = $_POST['phone']; // required $email = $_POST['email']; // not required $comments = $_POST['comments']; // required $email_message = "LOTR Contact Form.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "Name: ".clean_string($name)."\n"; $email_message .= "subject: ".clean_string($organisation)."\n"; $email_message .= "Phone: ".clean_string($phone)."\n"; $email_message .= "Email: ".clean_string($email)."\n"; $email_message .= "Comments: ".clean_string($comments)."\n"; // create email headers $headers = 'From:'.$email."\r\n". 'Reply-To: '.$email."\r\n" . 'X-Mailer: PHP/' . phpversion(); $ret = @mail($email_to, $email_subject, $email_message, $headers); setcookie("seeMeOnce", $ret); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title><?php bloginfo('name'); ?> <?php wp_title(); ?></title> etcline 42 being
setcookie("seeMeOnce", $ret);Any suggestions?
I have looked for whitespace, i have ob start in my header aswell.
The topic ‘PHP Form Error: (Warning Cannot modify header information…)’ is closed to new replies.