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

How do l set the request method so that values are accessible in the $_POST array

I have tried this.What am l missing.

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" name="flavor">

        <label for="flavor">Flavor</label>
        <select id ="flavor" name="flavor" REQUEST_METHOD="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>
        </select>

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

    </form>

</body>
</html>

2 Answers

Colin McGraw
Colin McGraw
15,337 Points

Your form should be posting data. You can take a look at the $_POST values by adding

var_dump($_POST);

at the top of process.php, and submitting the form. You also don't need a name attribute on your form, or REQUEST_METHOD on the select - but those wouldn't prevent your form from posting.

Jeff Lemay
Jeff Lemay
14,268 Points

The method on the form element is correctly set to post. The Request_Method attribute on the select element should be removed.

And then all your processing will be handled in process.php (value set in the action attribute on the form element).