Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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,598 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.

https://teamtreehouse.com/community/form-redirect-to-thanksphp

Alejandro Vazquez
Alejandro Vazquez
7,191 Points

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