loader image

PHP Program to display selected item from a list box

Write an HTML page to display a list of fruits in a list box. Write PHP program to display the selected fruits in a webpage.

<html>

<body>
    <form action="" method="POST">
        Choose any fruit
        <select name="fruits">
            <option value="Grape">Mango</option>
            <option value="Grape">Grape</option>
            <option value="Banana">Banana</option>
            <option value="Chicku">Chicku</option>
            <option value="Apple">Apple</option>
            <option value="Orange">Orange</option>
            <option value="Pine Apple">Pine Apple</option>
        </select><br><br>
        <input type="submit" value="SELECT">
    </form>
</body>

</html>

<?php
if ($_POST) {
    echo "<h2> You have selected : </h2>";
    echo $_POST["fruits"];
}
?>f
Output
fruits php
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Scroll to Top