Question: I have created a form on php that writes the result on a .txt file.

What happens is that on my server all is working good, but on another server there is the following error: 

> 
> Warning: Cannot modify header information - headers already sent by (output started at /home1/alertme/public\_html/mavala/form.php:43) in /home1/alertme/public\_html/mavala/form.php on line 52
> 
> 
> 

The code I am using is:

```
<?php
    if(isset($_POST['submit']))
    {
      $name = $_POST['name'];
      $email = $_POST['email'];
      $new_content = "\r\nNome: " . $name;
      $new_content .= "\r\nEmail: " . $email;
      file_put_contents('emaillist.txt', $new_content, FILE_APPEND);
      print_r(error_get_last());
      header('Location: thank-you.html');    //This is line 52
    exit();
    }
    ?>

```

The link of the server with the error is: <http://trendalert.me/mavala/form.php>

After filling the form and submit, the php writes the result on the .txt file but does not show the thank you page: <http://trendalert.me/mavala/thank-you.html>

Again, on my side it´s all working, but on the clients´server is not.

Answer: 
```
    <?php

```

is your issue, its sending white space which sends the headers.

Make sure that `<?php` is the very first thing in a php file 

also on a production server, them warnings should be suppressed
When using header you must not have any black space before your php open tag and any output before the header call. This behavior can change on different configuration and php versions.

So, remove all blank spaces and your print\_r and your problem will be fixed !