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 trialKim Gee
3,841 Pointscan't get the contact-thankyou.php page to show up after clicking the button. I am working on a server.
This is my code
<?php
if($_SERVER[βREQUEST_METHODβ] == "POST"){
$name = $_POST["name"];
$email = $_POST["email"];
$message = $_POST["message"];
$email_body = "";
$email_body =$email_body . "Name: ".$name . "<br>";
$email_body =$email_body. "Email: ".$email . "<br>";
$email_body=$email_body."Message: ".$message;
//todo- send email
header("Location: contact-thankyou.php");
exit;
}
?>
<form method="post" action="contact.php">
Kim Gee
3,841 Pointsthank you Colin. I didn't know how to format the post.
1 Answer
Jeff Lemay
14,268 PointsNot sure if this is your specific issue but want to throw out a common problem with using php's header function:
NOTHING can be printed to the page before you call the header function. If you have a blank line or even just a space before your opening php tag, the header will fail.
You also have the wrong kind of quotes around REQUEST_METHOD (β), should be ("). It shows a syntax error in sublime so that might be an issue.
Kim Gee
3,841 PointsThank you Jeff. It is working now.
Colin Marshall
32,861 PointsColin Marshall
32,861 PointsI fixed your code so it displays properly on the forum. Please read the Markdown Cheatsheet for instructions on how to post your code on the forum. You can also edit your original post to see what I did to fix it. Cheers!