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 trialFelix Bolton
2,750 Pointsredirection is not working?
After sumbmitting the form I'm not being redirected to the right page. When looking at this code i have personlised a few of the values etc. meaning it won't look exactly as it does in the video. But I still don't understand why it isn't working. Any help would be greatly appreciated.
<pre><?php
$name = $_POST["name"];
$email = $_POST["email"];
$house = $_POST["house"];
$order = $_POST["order"];
$email_body = "";
$email_body = $email_body . "Name: " . $name . "\n";
$email_body = $email_body . "Email: " . $email . "\n";
$email_body = $email_body . "House: " . $house . "\n";
$email_body = $email_body . "Order: " . $order;
// TODO: Send email
header("Location: order-thanks.php");
?></pre>
5 Answers
Andrew Molloy
37,259 Pointsorder-thanks.php definitely exists and is at the root of your site?
Andrew Molloy
37,259 PointsWhat happens when you do click submit? Nothing? Or sent somewhere else?
Felix Bolton
2,750 Pointsafter pressing submit i'm taken to http://www.noodleseller.com/order-process.php which is what the code i just posted is running on.
Andrew Molloy
37,259 PointsTry the full http address, in case it's a path issue on live server.
chrisp
13,686 PointsSo it seems that your form process is referring to itself and not processing the input fields. I would check the HTML codes. My best guess is the <button > tag is causing the problem. Assuming that you are using < button > </ button >
Try changing to
<input type="submit" value="submit" />
If that doesn't do it than I am not sure. But at time I think this may fix the problem using input. Hope that helps. Good luck.
Jason Anello
Courses Plus Student 94,610 PointsHi Felix,
Do you have those <pre>
tags in your file or did you just put them here thinking you needed them in the forum?
That would prevent the redirect from working. Any output before header
will prevent it from working.
Is that your entire order-process.php file? Do you have a blank line or any whitespace before your opening php block <?php
?
taahrqqhar
14,147 Pointsyou solved my problem thank you... I had a space before my <?php
Felix Bolton
2,750 PointsFelix Bolton
2,750 PointsAndrew it's definitely exists and is a root of my site