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
Wade Jordan
2,032 PointsStuck on Code Challenge: Build a Simple PHP Application > Integrating with PayPal > HTML Forms
I'm stuck on the second task of this code challenge. The challenge says to add an attribute to two different HTML elements. So I added method="post" to the form element to capture the form data and for the second part I added to the select element value="flavor". I know the method="post" part is right, but I don't know which attribute to use in the select element. The hint says: "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."
<form method="post" action="process.php">
<label for="flavor">Flavor</label>
<select id="flavor" value="flavor">
<option value="">— Select —</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>
7 Answers
Mauro Bonucci
5,953 PointsYes, i had the same problem, because my method POST was in Uppercase, but this should work im uppercase i think.
Sam Bass
9,038 Pointsneeds to be lower case "post" to work
Randy Hoyt
Treehouse Guest TeacherThe attribute you need here is name. If your select element looks like this ...
<select name="flavor"> ...
... then you can access the selected value on the server after a post submission like this ...
echo $_POST["flavor"];
The key in the $_POST array corresponds to the name on the HTML element.
Does that make sense?
Wade Jordan
2,032 PointsMakes sense. Thanks for the help.
Carlo Petermann
4,531 PointsOk, stuck here as well. I did use name attibute name within select,
<!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" name="flavor">
<option value="">— Select —</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>
Error returned: Bummer! It looks like you have added the right attribute (method) to the right element (the form), but it has the wrong value. Hint: we need to set the request method so that values are accessible in the $_POST array.
Thanks
Gregg Mojica
11,506 PointsI'm stuck on Pt. III, too. Any ideas?
Carlo Petermann
4,531 PointsHello Gregg,
In my case I had the method "post" written in uppercase. Lowercase solved the problem.
Hope this helps
Wade Jordan
2,032 PointsCarlo, check for case sensitivity.
Carlo Petermann
4,531 PointsI knew it was something stupid...thx