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 trialAlex Boltava
896 Pointsheader() method has no effect
I've tried to use different examples of header("Location: name.php");, but nothing seems to work. I still get the contact-process.php page. What might be wrong?
3 Answers
Jason Anello
Courses Plus Student 94,610 PointsCan you post your code?
https://teamtreehouse.com/forum/posting-code-to-the-forum
header
doesn't work if you output any html before it. Having a blank line before your opening php tag is considered output and would be one cause on why this is not working.
Samiruddin Syed
3,136 PointsTh header function works only if you write it correctly, notice the "L" in your header location is in uppercase letters. It should be header("location:name.php");
Try to avoid spaces where they aren't required :)
Hope that helps.
Jason Anello
Courses Plus Student 94,610 PointsThe examples on this page http://www.php.net/manual/en/function.header.php show it with both an uppercase 'L' and a space after the ':'
Samiruddin Syed
3,136 PointsCan you post the code of the page here ?
Alex Boltava
896 PointsAlex Boltava
896 PointsI figured out the problem: I had an
echo
statement right before the header() function. I'm really new to PHP, so that didn't seem wrong at first :) Thank all of you for help! I really appreciate it.