php - how do get information from a dropdown box and multiple checkboxes to show my output

Im currently trying to make an application in php that gets user input from a input-box that converts units that is chosen by a dropdown box to multiple checkboxes. (example I put 2 in the input box and select inches from the dropdown box, then check cm, yard, and foot check boxes. It will display the measurements from inches to cm, yard, and feet.) Im currently stuck getting the arrays to input and am stuck on what to do.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
        <lable><input type="" name="Unit1" id="Unit1"></lable>
        <!-- dropdown -->
        <select name="Unit1" id="Unit1">
            <option value="meter">meter</option>
            <option value="mm">mm</option>
            <option value="cm">cm</option>
            <option value="km">km</option>
            <option value="inch">inch</option>
            <option value="yard">yard</option>
            <option value="foot">foot</option>
            <option value="mile">mile</option>
        </select>
        -->
        <!-- checkbox -->
        <input type="checkbox" id="meter" name="meter" value="meter">Meter<label>
        <input type="checkbox" id="mm" name="mm" value="mm">mm</label>
        <input type="checkbox" id="cm" name="cm" value="cm">cm</label>
        <input type="checkbox" id="km" name="km" value="km">km</label>
        <input type="checkbox" id="inch" name="inch" value="inch">inch</label>
        <input type="checkbox" id="yard" name="yard" value="yard">yard</label>
        <input type="checkbox" id="foot" name="foot" value="foot">oot</label>
        <input type="checkbox" id="mile" name="mile" value="mile">mile</label>
        <p></p>
        <!-- Unit 2 -->
        <lable><input type="" name="Unit2" id="Unit2"></lable>
        <!-- dropdown -->
        <select name="Unit2" id="Unit2">
            <option value="liter">liter</option>
            <option value="oz">oz</option>
            <option value="gallon">gallon</option>
            <option value="quart">quart</option>
            <option value="pint">pint</option>
            <option value="tab_spoon">tab_spoon</option>
            <option value="tea_spoon">tea_spoon</option>
            <option value="cup">cup</option>
        </select>
        -->
        <!-- checkbox -->
        <input type="checkbox" id="liter" name="liter" value="liter"><label for="liter"> liter</label>
        <input type="checkbox" id="oz" name="oz" value="oz"><label for="oz"> oz</label>
        <input type="checkbox" id="gallon" name="gallon" value="gallon"><label for="gallon"> gallon</label>
        <input type="checkbox" id="quart" name="quart" value="quart"><label for="quart"> quart</label>
        <input type="checkbox" id="pint" name="pint" value="pint"><label for="pint"> pint</label>
        <input type="checkbox" id="tab_spoon" name="tab_spoon" value="tab_spoon"><label for="tab_spoon"> tab spoon</label>
        <input type="checkbox" id="tea_spoon" name="tea_spoon" value="tea_spoon"><label for="tea_spoon"> tea spoon</label>
        <input type="checkbox" id="cup" name="cup" value="cup"><label for="cup"> cup</label>
        <p></p>
        <!-- button -->
        <button type="submit">Convert</button>
    </form>
    <?php
        var_dump($_REQUEST);
        // $measurement = (int)$_REQUEST["Unit1"];
        
    ?>
</body>
</html>

Answer

Solution:

The beginning of your form is missing the form tag.

<form>

You also need to give the inputs a separate names so you can differentiate them in your array. Currently you are using the same name for the value and the type. Use something like Unit1_value and Unit1_name to differentiate between the two

    <lable><input type="" name="Unit1_value" id="Unit1_value"></lable>
    <!-- dropdown -->
    <select name="Unit1_name" id="Unit1_name">

Answer

Solution:

You can name the element from your form in array like here Html/PHP - Form - Input as array so you can differentiate each of the conversion that you want easily

you might also find this helpful How to get multiple selected values of select box in php?

Source