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

I make the method = post and i create a submit button; what special attribute should i put in the select tag?

i dont find anything which can access post data from server please help

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

        <label for="flavor">Flavor</label>
        <select id="flavor" <?php $a= $_POST; ?> >
            <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>
          <?php $_POST=value ?>
        </select>
        <input type="submit" value="Submit">


    </form>

</body>
</html>

1 Answer

This line:

<?php $_POST=value ?>

will give you a syntax error - plus probably best not to overwrite the super global $_POST variable! I would remove this line.

remove the php from the select element:

<select id="flavor" <?php $a= $_POST; ?> >

You'll need to give the select element an attribute of name to pass it through the form submission and access it via $_POST['flavor']

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