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