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

Andrew Dovganyuk
Andrew Dovganyuk
10,633 Points

Please any one help!

Do not understand what should do in task4!

$flavor = $_POST["flavor"];
$id = $_POST["order_id"];

<!DOCTYPE html>
    <title>Ye Olde Ice Cream Shoppe</title>

    <p>Your order has been created. What flavor of ice cream would you like to add to it?</p>

    <form method="post" id="7546" action="process.php">

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

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



2 Answers

Umesh Ravji
Umesh Ravji
42,359 Points

You can't create an option because that would let the user select it, and you don't want the user to be able to see this order_id value, at least I think, (or letting them change it could be dangerous.. but I think you will learn more about security later on).

You would have seen an text input before, which lets the user enter some data, such as:

<input type="text" name="username">

which would give access to a $_POST['username'] variable.

If you want to send data that the user is not able to visually see, you could send it using a hidden input element.

<input type="hidden" name="fruit" value="orange">

this would give access to a $_POST['fruit'] variable, which will have a value of 'orange'. This is an element the user cannot edit (well they could edit the HTML) or see.

Andrew Dovganyuk
Andrew Dovganyuk
10,633 Points

Thanks bro for your TIME!!! ;)

Umesh Ravji
Umesh Ravji
42,359 Points

Hey there. Your not actually writing any PHP for this challenge, let me put the question to you in a different way.

Once the form is submitted, the process.php file wants to be able to access a variable in the $_POST array, with the element being accessed using $_POST['order_id'].

It is up to us to make sure that this variable exists for the process.php file. In the first step you gave the select a name of 'flavor' to ensure that that the value of $_POST['flavor'] is available to process.php. Now, your task is to create an element in the html that has a name of 'order_id' and a value of '1234' or whatever it's supposed to be. Hint, there is an input element with type 'hidden'.

Does that make it clear?

Andrew Dovganyuk
Andrew Dovganyuk
10,633 Points

Dont get it! :) Do I need create another <option>?

Andrew Dovganyuk
Andrew Dovganyuk
10,633 Points

Thank you Umesh I got it what I needed is just this:

<input type="hidden" name="order_id" value="7546">