1// Page containing a form:
2<form action="myaction.php" method="post">
3 <select name="fruit">
4 <option value="Apple">Apple</option>
5 <option value="Banana">Banana</option>
6 </select>
7 <input type="submit" value="Submit">
8</form>
9
10// myaction.php
11Hello <?php echo htmlspecialchars($_POST['fruit']); ?>
1<?php
2 if(isset($_POST['submit'])){
3 if(!empty($_POST['Fruit'])) {
4 $selected = $_POST['Fruit'];
5 echo 'You have chosen: ' . $selected;
6 } else {
7 echo 'Please select the value.';
8 }
9 }
10?>