How to get selected value from DropDownList in php

Retrieve and Display drop down list selected value text on same page.

In this tutorial we are creating a simple drop down list using label tag with option value. After that we are receiving drop down list value using $_Post method and display using echo function on screen. So here is the complete step by step tutorial for How to get selected value from DropDownList in php.

android-project-download-code-button

How to get selected value from DropDownList in php.

Code for drop-down-list-get.php file.

 <!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>How to get selected value from DropDownList in php</title>
</head>

<body>

<h2>Get selected value from DropDownList in php</h2>

<form method="post" action="">
 
 <label >Subjects</label>
 
 <select name="Subjects_Name">
 <option>---Select Subject--</option>
 <option value="Android">Android</option>
 <option value="Php">Php</option>
 <option value="Java">Java</option>
 <option value="C++">C++</option>
 </select>

 <button type="submit" name="submit" >Submit</button>
 
 </form>

<?php
if(isset($_POST["submit"]))
{
 
$subject_names=$_POST["Subjects_Name"];

echo '</br>' . " Drop Down List Value is : " . $subject_names;

}
?>

</body>
</html>

Screenshot:

How to get selected value from DropDownList in php

Click here to download How to get selected value from DropDownList in php project file with source code.