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

Redirecting after form submission doesn't work for me, even tho I copied code on the video. Worked before last stage

Worked right up until I split off part into contact-thanks.php and left the rest in contact-process.php. I checked and checked against the code in the video and it looks the same. What am I supposed to do in this situation? I don't want to move on until this is sorted but I can't see the problem. this is downfall of this kind of learning imo.

ok, I got it but I don't believe this wasn't mentioned on the video. apparently if there is even one blank line in your file, before the <?php it doesn't work. If it wasn't mentioned, perhaps it could be added? If it was, perhaps it could be reinforced? It's a pretty big problem because there is absolutely no feedback on what is wrong. and it stops everything from working, even when everything else in the file is correct

4 Answers

Hi Penny,

I can't remember if it was mentioned in the videos or not, but yeah, header doesn't work if there is any output to the page before it.

Here's a link to the header documentation which may help: http://php.net/manual/en/function.header.php

Thanks for header doc link.... However I do think it's something that could be mentioned a few times in the video tutorials - if it's even mentioned at all! It's such a difficult thing to spot if you are new to php, and such a horrible time-sink trying to work out what is wrong! (and thanks Robert, for letting me know I'm not alone in doing this - I'm sure there are plenty of us!) In the tutorials there are numerous warnings about leaving off semi-colons and other syntactical errors, but imo this is a much more sneaky problem!
I understand you don't want to re-record tutorials but maybe a FAQ that contains this problem - ie things to check if your php code isn't working (I looked for this but couldn't find it, perhaps it exists?)

The only thing I know about is that some videos will have a Teacher's Notes section which they use to put up additional information. Or sometimes corrections will be there if an error is found in a video. Not all videos have this though.

Robert Wasinger
Robert Wasinger
12,385 Points

Same thing happened to me the other day. Glad to hear I wasn't the only one!

Van Doan
Van Doan
32,285 Points

I just had the same problem, and I kinda have to chuckle. Penny, I hope you're still coding, and yes, you'll have a lot of "time-sinks" while learning to code. And one coder told me, "learn to love it. It's when you realllly learn about a language."

Thanks for the post and answer!

Kevin Phillips
Kevin Phillips
15,693 Points

I stepped in this too! I like how the "dreaded code" appears on Line 13 (ahhh!) of Randy's program! Dun dun duunnn!