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
Shannon Weaver
973 PointsWhat am I doing wrong??????
Notice: Undefined index: message in C:\xampp\htdocs\shirts4mike\contact-process.php on line 4 Shannon Weavershannondawnweaver@outlook.com
This is the error message I keep getting after I try this code.... <?php $name = $_POST["name"]; $email = $_POST["email"]; $message = $_POST["message"];
echo $name; echo $email; echo $message; ?>
What am I doing wrong? It looks just like it does in the video... ugh I am so stuck. Please help.
Thanks, Shannon
4 Answers
Patrick Stephens
8,237 PointsThe error is telling you that it can't find one of the keys you have entered for $_POST. This means that the name attribute for the form element you are trying to collect data from does not exactly match the key you have given $_POST. I would check for a typo in your html form.
Sean T. Unwin
28,690 PointsAs well as what Patrick Stephens has said, I think it is specifically the message in your HTML form that has a typo in it.
Shannon Weaver, I would also suggest you edit your post to remove the email address. :)
Faizal Heesyam
8,843 Pointsare you trying to load this page while nothing was actually submitted yet? coz the $_POST will only return a value IF there's a post action submitted.
try to do some isset() before you going to display the $_POST variables value like this:
<?php
if(isset($_POST['name'])) { $name = $_POST['name']; }
echo $name;
?>
nik
8,925 PointsSo your problem is on line 4. most of the time the problem is cause your missing a punctuation or closing mark. Line 4 should be
$email = $_POST["email"];
your contact-process.php file should look like this:
<?php
$name = $_POST["name"];
$email = $_POST["email"];
$message = $_POST["message"];
echo $name;
echo $email;
echo $message;
?>
And also make sure your name and id is correct in your contacts.php file Good luck =)
Oh you've figured it out lol disregard this long post =P
Shannon Weaver
973 PointsShannon Weaver
973 PointsThank you for your help! I did have a typo in my html but I could not see it until I left my computer for a few hours. Whew glad that is over until the next time. LOL Shannon