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 Basic PHP Website (2018) Adding a Basic Form Utilizing Object Properties and Methods

Jon Benham
Jon Benham
6,444 Points

Email Form always defaulting to "Please fill in the required fields: Name, Email and Details"

Hi,

I seem to be having trouble with submitting the email, whatever I do the code resorts to the first 'if' statement and outputs "Please fill in the required fields: Name, Email and Details".

I feel like I have followed the videos and code closely but clearly I am missing something somewhere!

Can anyone help?

I have attached a snapshot of my code here https://w.trhou.se/7b2vlx13lj

3 Answers

In suggest.php I added the following before your if statement:

echo $name . " " . $email . " " . $details;

and found that $details was blank

If you go to line 80 you'll find the name is details where it should be address

      <td><input type="text" name="details" id="address">

should be

      <td><input type="text" name="address" id="address">
Pascal Breitrück
PLUS
Pascal Breitrück
Courses Plus Student 3,206 Points

Hey Jon,

fix the name propertie on the input field for the address . There is details set and this will overwrite the details in a blank field.

<td><input type="text" name="address" id="address" value="">

Ps. Use the var_dump() func. to debug things ;D like the $_POST :D

Greets Pascal

Jon Benham
Jon Benham
6,444 Points

Thanks all, sorry for the delayed reply but this did work!