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 Integrating with PayPal HTML Forms

Patrick Koch
Patrick Koch
40,498 Points

dont understand the task.

Code Challenge HTML Form Task 2/3

Next, we need the flavor selected in the dropdown to be submitted to this process.php file. We need to be able to access it in the β€œflavor” element of the $_POST array, like this: $_POST["flavor"]. What two changes do we need to make to the HTML? (Hint. We need to add two new attributes. The first needs to be added to one existing HTML element, the second needs to be added to a different existing HTML element.)

so what I understood, when we press the submit button the form gets as an array, send to the process.php. I want to access of the selected and submitted, "flavor", so I need to give that element(flavor) out of submitted array a name to reach it.

Did i understood it right? and how i achieve to to give the flavors elements a specific name?

Greetings Patrick

2 Answers

Mike Baxter
Mike Baxter
4,442 Points

Not quite. When you use the $_POST method, the form only sends the name and value of the selected option; it does not send an array of all options.

However, the question is trying to get you to realize two things:

  1. The form isn't actually sending anything to "process.php" yet. You have to tell it to do that with the "action" attribute.
  2. The <select> array only has an id attribute, it doesn't have a name attribute, and forms need to pass the name through; they don't care about the id.
Patrick Koch
Patrick Koch
40,498 Points

Thanks alot,

I was playing around a little bit with POST and Get, I think i got it now!

thanks alot