Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Adebayo Ojo
23,649 PointsNotice: Undefined index: name/email in C:\wamp64\www\phpsite\process.php on line 2/3
I'm getting undefined index on line 2 and line 3 when I browse to my process.php page.
My code:
<?php $name = $_POST["name"]; $email = $_POST["email"]; $details = $_POST["details"];
echo "<pre>"; $email_body = ""; $email_body.= "Name ".$name. "\n"; $email_body.= "Email ".$email. "\n"; $email_body.= "Details ".$details. "\n"; echo "</pre>"; ?>
2 Answers

Simon Coates
28,693 Points$_POST not $POST

Adebayo Ojo
23,649 PointsThe was in my php.ini file. I had to edit the SMTP and smtp_port field with the same detail I have in my suggest.php code, and it's working perfectly now. I can send and receive email right from my local machine.
Adebayo Ojo
23,649 PointsAdebayo Ojo
23,649 PointsApparently it's this platform that messed up my code, because I have it correctly on my IDE. My code has the underscore but when I paste it here, the underscore is removed somehow. So with the correct code following the teacher, I'm still getting the "Undefined" error.
Simon Coates
28,693 PointsSimon Coates
28,693 Pointsundefined index means it isn't finding the value for one of the keys. You can take a look at what is on $_POST using var_dump($_POST ). I'll demo the error.
produces:
So you can look at what is stored in $_POST to see if anything is missing, and then you can look at the name attribute on the various input elements to see if there are any mismatches. Either you have the wrong key, are using GET not POST, or one of your values isn't being sent.
Adebayo Ojo
23,649 PointsAdebayo Ojo
23,649 PointsSee my var_dump output below. I don't know why the first two array keys(name and email) are having an underscore in the front. The actual code does not have anything like that.
C:\wamp64\www\phpsite\process.php:11: array (size=3) 'name_' => string 'Ojo Adebayo' (length=11) 'email_' => string 'bayoojo1@yahoo.com' (length=18) 'details' => string 'message' (length=7)
Simon Coates
28,693 PointsSimon Coates
28,693 Pointsthe name attribute on the input form elements should determine what key your values have inside $_POST.