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 HTML Forms

Javier MARQUEZ
Javier MARQUEZ
11,877 Points

I am stuck

Sorry for bothering you guys, could you give me a hand?

I am having a hard time with the 4th task of this code challenge. I am supposed to identify the order with an order number. I am absolutely lost, can someone copy paste his code to see what they mean, I really dont understand the question. Here is my code.

Thanks a whole lot.

index.html
<!DOCTYPE html>
<html>
<head>
    <title>Ye Olde Ice Cream Shoppe</title>
</head>
<body>

    <p>Your order has been created. What flavor of ice cream would you like to add to it?</p>

    <form method="post" action="process.php">

        <label for="flavor">Flavor</label>
        <select id="flavor" name="flavor">
            <option value="">&#8212; Select &#8212;</option>
            <option value="Vanilla">Vanilla</option>
            <option value="Chocolate">Chocolate</option>
            <option value="Strawberry">Strawberry</option>
            <option value="Cookie Dough">Cookie Dough</option>
        </select>

        <input type="submit" value="Update Order">

    </form>

</body>
</html>
Javier MARQUEZ
Javier MARQUEZ
11,877 Points

These are the instructions

Challenge Task 4 of 4

Finally, we need the form to submit a unique identifier for the order to the process.php file. We need to be able to access that value in an order_id element of the $_POST array, like this: $_POST["order_id"]. For this particular order, the order ID should be 7546. We don't want this value displayed in the browser, though. What do we need to add to the form? (Hint: We need to add a new HTML element with three attributes.)

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

What it's looking for is a hidden input element with the type equal to hidden, name equal to order_id, and the value equal to 7546. Add the input immediately before the closing tag of your form.

   <input type="hidden" name="order_id" value="7546">

Your answer worked but I don't understand why based on the instructions.

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Veronica Rivera I'm sorry. I'm not sure what's unclear. Is it the instructions or my answer? Can you tell me where it's confusing and maybe I can find a better way to explain?

Jennifer Nordell Your answer worked it's just that from watching previous videos and based on the instructions, nothing would have crossed my mind that the input tag is the appropriate tag for the answer. It's more of something that I think the instructors failed to cover in the course.

So I guess my question is, why the input tag?

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Veronica Rivera You might be correct. To be fair, it's been a while since I've looked at this course. However, the big hint here is that they want a form element and it should not be displayed in the browser. There are several form elements that can be disabled (aka grayed out). But only the input can be made as type="hidden".

:information_source: Here's some documentation from w3c.

https://www.w3.org/wiki/HTML/Elements/input

If you look on the right side you'll see links to different form elements, and if you go through them you'll see that only input can be hidden. Hope this helps!

Jennifer Nordell Thanks for the thorough explanation. I greatly appreciate it. Makes perfect sense now.

Enea Jorgji
Enea Jorgji
6,038 Points

Hello Jennifer, what is the reason to add this line?

Javier MARQUEZ
Javier MARQUEZ
11,877 Points

Thanks a lot, I just made it trough the code challenge!