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

Kevin Dunn
Kevin Dunn
6,623 Points

Problems with html/php contact form

Hi, I have a problem with my contact form that I have created. When the user clicks on the send email button, I receive the email, but I can't see the user's input. So basically I am not able to see the contents of $email and $message. What could be wrong?

<?php

$email = $_POST['email'];
$message = $_POST['message'];

$to = "testemail@testemail.com";
$subject = "New Message!";
$body = "This is an automated message. Please do not reply to this email. \n\n $email \n\n $message";

mail($to, $subject, $body);
echo "Message Sent.";
?>
<form id="contact-me-form" action="contact.php" name="contact_form "method="post">
     <input type="text" name="email" placeholder="Email Address">
     <textarea name="message" placeholder="Type Your Message Here"></textarea>
     <input id="sendEmail" type="submit" name="submit" value="Send">
</form>

Kevin Dunn:

Look at your 1st form line. You typed: "method="post". You don't need the " before method. Be careful when you type. Small errors like that will cause you great frustration. Syntax is very specific.

1 Answer

Luc de Brouwer
seal-mask
.a{fill-rule:evenodd;}techdegree
Luc de Brouwer
Full Stack JavaScript Techdegree Student 17,939 Points

I believe I read somewhere you need to configure a local mail server with php in order to send mail through php contact forms to other persons