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

Stuck on another code challenge, help please...

Hello again, so now I am stuck on stage 5 Integrating with PayPal - HTML Forms code challenge. I need to add two attributes to two html elements. So here is my code:

<!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 action="process.php" method="post">

    <label for="flavor">Flavor</label>
    <select id="flavor" method='<?php $_POST["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>

It's the attribute on the select element which is not passing. The error message reads: Bummer! It looks like you have added an attribute to the select element, but it's not the attribute that determines how to access the value on the server.

Any hep would be much appreciated.

1 Answer

Hi! The main problem with your code is in your <select> tag. It is not correct to include a method attribute within the <select> tag, you simply need to give it a name. The correct code for this is:

<select id="flavor" name="flavor">

The name attribute specifies what is passed through via POST, you do not need to use any PHP at this time. Because you have specified the name of your select box as flavor, you will be able to access the response to this input using $_POST[flavor] on the following page.

Hope that helps.

Hi Fraser, yes that does help :)

Thank you for the explanation, sometimes I need it spelling out a few times before it sticks!