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 Working with Post Variables

Genevieve Tan
Genevieve Tan
4,257 Points

unable to echo message properly

Hi, I am able to echo var_dump name and email, however when i add message , the entire page goes blank. This is the section of my html code on the contact form.

<form method="post" action="contact-process.php"> <table> <tr> <th> <label for="name">Name</label> </th> <td> <input type ="text" name="name" id="name"> </td> </tr> <tr> <th> <label for="email">Email</label> </th> <td> <input type ="text" name="email" id="email"> </td> </tr> <tr> <th> <label for="message">Message</label> </th> <td> <textarea name="message" id="message"></textarea> </td> </tr> </table> <input type="submit" value="send"> </form>

And this is the code for my contact-process.php

<?php echo 'Tan'; var_dump($_POST); $name = $_POST["name"]; echo $name; $email = $_POST["email"]; echo $email; /$message = $_POST["message"] echo $message;/

?>

It runs perfectly until i uncomment the message variable. I don't understand whats wrong. Help

Genevieve Tan
Genevieve Tan
4,257 Points

Opps i realised i missed a semi colon. Cost me 1 hr to find it T.T

Jeff Lemay
Jeff Lemay
14,268 Points

Won't be the last time! :)

3 Answers

Jeff Lemay
Jeff Lemay
14,268 Points

No semi-colon after $_POST["message"]

Kristoffer Lund
Kristoffer Lund
11,133 Points

You are missing a semi colon after $_POST["message"].

Dont you need a semicolon after the statement loading $message? $message = $_POST["message"]; <-- Semicolon here echo $message;