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 Simple PHP Application Adding a Contact Form Redirecting After a Form Submission

Scott Dunstan
Scott Dunstan
12,517 Points

Header() not working?

I couldn't for the life of me figure out why header() didn't seem to be functioning - turns out it was because I had a blank line at the top of the contact-process.php page. That blank line, and in fact any blank lines in that code constitutes output and renders the header() function ineffective on account of there being a rule that the code cannot produce ANY output BEFORE you call the header() function!

do you mean that you had a blank line before your opening php tag?

I think it's ok to have blank lines within the php script.

3 Answers

Scott Dunstan
Scott Dunstan
12,517 Points

Yep, line 1 was blank, and my "<?php" tag started on line 2.

Ok, that makes sense based on what else I've read. After the php tag you should be able to do other processing and have blank lines before the header.