PHP Build a Basic PHP Website (2018) Adding a Basic Form HTML Forms

how do I handle this .The code below contains a simple HTML form. It looks fine in the browser, but it does not send the

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

<?php

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

index.html
<?php
<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>
<?php

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

2 Answers

Andy Watts
Andy Watts
20,836 Points

A form tag needs an action method. An action method tells the browser, where to send the data that the user filled in. It could go to the same page or it can go to a different page.

<form action="process.php">
 /*form here*/
</form>
jason chan
jason chan
31,004 Points

you have to use a form action. You only need to know two. Post and get.

http://php.net/manual/en/tutorial.forms.php

http://php.net/manual/en/reserved.variables.get.php

Post to database. Get to read the data from database.

GL.