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.
Can't figure out the bug!
I have the same code, but where I try to press submit the site is redirecting me in blank page where is written: Warning: Cannot modify header information - headers already sent by (output started at /Applications/MAMP/htdocs/shirts4mike/contact.php:2) in /Applications/MAMP/htdocs/shirts4mike/contact.php on line 14 Can someone help me?
Jeff Lemay14,266 Points
PHP's header function will not work if anything is being printed to the page before you call the function. It's okay to have if/else statements and other php before you call the header function to go to a new page, but if you have an empty line or space at the top of your document before opening your php tags, the header will fail. Frustrating.
I can't see specifically what's causing your issue in the code you posted. Here's in-depth details to help you troubleshoot:
Try moving the comment at the top of the page to the next line. Make sure there are no spaces after the open tag: <?php
Thanks, I even can't imagine that this was a problem.