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 trialJamaal Todd
5,689 PointsPHP header not redirecting
Okay so, ive tried reading all the different discussions to try help me, but I cant seem to find anything (maybe its there, and im just not picking it up).
Everything woks fine up until I add in the header(Location: "contact-thanks.php").
Thanks in advance! :)
Jamaal Todd
5,689 Pointscontact-thanks.php
<?php
$pageTitle = "Contact Mike";
$section = "contact";
include("inc/header.php")
?>
<div class="section page">
<div class="wrapper">
<h1>Contact</h1>
<p>Thanks for the email! I’ll be in touch shortly.</p>
</div>
</div>
<?php include("inc/footer.php"); ?>
4 Answers
Hugo Leon
7,763 PointsMake sure you have set the name of your file correctly. 404 Error shows up when the page can't be found.
Jamaal Todd
5,689 PointsThanks Mike!
I found it just before I read your comment, and your comment backed it up!. I had my file saved as
"contact.-thanks.php" instead of "contact-thanks.php"
Little typo had me running around, thanks for the help!
Hugo Leon
7,763 PointsHello Jamaal!
The function header needs a String as a required parameter. You must pass the string to the function as follows:
header("Location: contact-thanks.php");
Hope it helps!
Jamaal Todd
5,689 PointsHi Hugo! :)
Thanks for the fast reply.
I've posted my code up above. I realise I did have it as you specified, can you plesae check over my code and see if theres anything wrong?
When I click submit, it goes to a page that says "object no found... etc... "
Thanks
Hugo Leon
7,763 PointsI do not see any problems in the code. But maybe you could try to show errors that may be generating your application. You could add the following lines at the beginning of your PHP file temporarily.
ini_set('display_errors', 1);
error_reporting(E_ALL);
Jamaal Todd
5,689 PointsI added in the line of code like you said? im wondering if my position is right?. Im not sure what its doing , but I cant see it making any difference.
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
$pageTitle = "Contact Mike";
$section = "contact";
include("inc/header.php");
?>
<div class="section page">
<div class="wrapper">
<h1>Contact</h1>
<p>Thanks for the email! I’ll be in touch shortly.</p>
</div>
</div>
<?php include("inc/footer.php"); ?>
p.s thanks for the hlep
Hugo Leon
7,763 PointsI see, maybe the semicolon after including the header:
include("inc/header.php");
Jamaal Todd
5,689 PointsI have corrected that now, but problem still happens. Object not found.... Error 404... etc
include("inc/header.php");
Jamaal Todd
5,689 PointsJamaal Todd
5,689 Pointscontact-process.php