Tips and Tricks

Causes for php Warning: Cannot modify header information - headers already sent

Build Online Forms for your own Web Site !

Arclab® Web Form Builder the HTML form creation software for Windows PC to create email contact forms and
multi-page php forms with ease. Build HTML forms on your PC and upload the forms to your own web site.

 

Arclab Web Form Builder Homepage

You will not get this error as long as you don't edit the php File created by Arclab Web Form Builder!

 

Echo before header

<?php
echo "hello world"
...
header('Location: http://...');
?>

Solution:

RemoveRemove the echo before header
Use ob_start(); and ob_end_flush(); for buffered output

 


 

New-line characters or spaces before <?php

       <?php
... header('Location: http://...');
?>

Solution:

Remove everything before <?php

 


 

BOM (Byte-Order-Mark ) in utf-8 encoded php files

 <?php
...
header('Location: http://...');
?>

Solution:

Change the file encoding to "without BOM" (e.g. using notepad++) or remove the BOM before <?php using a HEX editor

 


 

Header Location in mixed php/HTML

<html>
...
<body>
...
<?php header('Location: http://...'); >
...
</body>
</html>

Sorry, you cannot use header-location here, because the header and the HTML code have already been sent!

 


 

Empty lines, chars or spaces after ?> when using an php include file

<?php
...
?>

   ...
...

Solution:

Remove everything after ?> in the php include file