Title: PHP Form Error: (Warning Cannot modify header information&#8230;)
Last modified: August 20, 2016

---

# PHP Form Error: (Warning Cannot modify header information…)

 *  [chrisando](https://wordpress.org/support/users/chrisando/)
 * (@chrisando)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/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](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 = "me@chrisando.com";
           $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>
   
       etc
       ```
   
 * line 42 being
 * `setcookie("seeMeOnce", $ret);`
 * Any suggestions?
 * I have looked for whitespace, i have ob start in my header aswell.

Viewing 1 replies (of 1 total)

 *  [kmessinger](https://wordpress.org/support/users/kmessinger/)
 * (@kmessinger)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/php-form-error-warning-cannot-modify-header-information/#post-2206173)
 * The message refers to themes lotr/contact.php line 3. It looks like on the third
   line of code there is an extra space between the ending ) }
 * BTW, if you are going to paste more than 10 line of code please use [http://www.pastebin.com](http://www.pastebin.com)
   per [http://codex.wordpress.org/Forum_Welcome](http://codex.wordpress.org/Forum_Welcome)

Viewing 1 replies (of 1 total)

The topic ‘PHP Form Error: (Warning Cannot modify header information…)’ is closed
to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [kmessinger](https://wordpress.org/support/users/kmessinger/)
 * Last activity: [14 years, 10 months ago](https://wordpress.org/support/topic/php-form-error-warning-cannot-modify-header-information/#post-2206173)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
