Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP Build a Basic PHP Website (2018) Adding a Basic Form Redirecting After a Form Submission

I'm getting a duplicate header error

Warning: Cannot modify header information - headers already sent by (output started at /home/content/03/12651803/html/techbuyer/inc/header.php:47) in /home/content/03/12651803/html/techbuyer/inc/offer.php on line 48

Anyone know how to fix the above error?

3 Answers

Codin - Codesmite
Codin - Codesmite
8,600 Points

Check if you have any whitespace before or after your php opening/closing tags

<?php ?>

in your header.php include file.

Whitespace can cause a premature output in PHP which can cause the above error.

I encountered the same issue and the solution over at the post below fixed it for me. I'm running MAMP locally and Output Buffering is not enabled by default so the function obstart() needs to be run for the warning to disappear.


Alejandro Vazquez
Alejandro Vazquez
7,191 Points

I am getting the same error and I have no white space.