{"id":14799,"date":"2016-10-03T16:15:45","date_gmt":"2016-10-03T13:15:45","guid":{"rendered":"http:\/\/www.webcodegeeks.com\/?p=14799"},"modified":"2018-01-09T10:26:41","modified_gmt":"2018-01-09T08:26:41","slug":"php-form-dropdown-example","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/php\/php-form-dropdown-example\/","title":{"rendered":"PHP Form Dropdown Example"},"content":{"rendered":"<p>In this example we will learn how to handle data from a drop-down-list in HTML with PHP.<br \/>\nFor this example we will use:<\/p>\n<ol>\n<li>A computer with PHP&gt;= 5.5 installed<\/li>\n<li>notepad++<\/li>\n<\/ol>\n<p>We will show you how to add select boxes and multi-select boxes to a form, how to retrieve the input data from them and how manipulate the data.<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n[ulp id=&#8217;8njY7i2QRy6sg8pg&#8217;]<\/p>\n<h2>1. Getting Started<\/h2>\n<p>To fully understand HTML drop-down-list, we have to grasp the concept of HTML forms. This is because HTML drop-down-list is mostly contained in HTML form tags.\u00a0HTML forms allow user&#8217;s to send data to a server or website. HTML forms are created with the opening <code>&lt;form&gt;<\/code> and closing <code>&lt;\/form&gt;<\/code> tag. The<code>form<\/code> tag defines an html form.<br \/>\nForm elements are different, they can be text fields, checkboxes, radio buttons, submit buttons, and more.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>index.php<\/em><\/span><\/p>\n<pre class=\"brush:html; highlight:[23]\">           \r\n&lt;!DOCTYPE html&gt; \r\n&lt;html lang=eng&gt;\r\n\t&lt;head&gt;\r\n\t&lt;style&gt;\r\n\thtml, body{\r\n\twidth:100%;\r\n\theight:100%;\r\n\tmargin:0%;\r\n\tfont-family:\"helvetica\",\"verdana\",\"calibri\", \"san serif\";\r\n\toverflow:hidden;\r\n\tpadding:0%;\r\n\tborder:0%;\r\n\t}\r\n\t \r\n\t&lt;\/style&gt;\r\n\t \t\t&lt;meta charset=\"utf-8\" \/&gt;\r\n\t\t&lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, target-densitydpi=device-dpi\"\/&gt;\r\n\t\r\n\t&lt;title&gt;HTML Form&lt;\/title&gt;\r\n\t\r\n\t&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;form action=\"index.php\" method =\"post\"&gt;\r\nName: \r\n&lt;input type =\"text\" name =\"name\" required&gt;\r\n&lt;br&gt;\r\nE-mail: \r\n&lt;input type =\"email\" name =\"email\" required&gt;\r\n&lt;br&gt;\r\n&lt;input type=\"submit\" value=submit&gt;\r\n&lt;\/form&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p>The code above creates an html form. The &#8220;action&#8221; attribute in the form tag(line 23) tells the form where to submit its content while the &#8220;method&#8221; attribute let&#8217;s the form know which method to use when transmitting its content. The method attribute can either be <code>GET<\/code>or <code>POST.<\/code><\/p>\n<h3>1.1 HTML Drop-down-list<\/h3>\n<p>A drop-down list is also known as a pull down box or select box.\u00a0A select box contains one or more \u201coptions\u201d. Each option has a \u201cvalue\u201d, just like other inputs, and also a string of text between the option tags.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>index.html<\/em><\/span><\/p>\n<pre class=\"brush:html; highlight:[31,32,33,34,35,36,37,38,39,40,41]\">  \r\n&lt; !DOCTYPE html&gt; \r\n&lt;html lang=eng&gt;\r\n\t&lt;head&gt;\r\n\t&lt;style&gt;\r\n\thtml, body{\r\n\twidth:100%;\r\n\theight:100%;\r\n\tmargin:0%;\r\n\tfont-family:\"helvetica\",\"verdana\",\"calibri\", \"san serif\";\r\n\toverflow:hidden;\r\n\tpadding:0%;\r\n\tborder:0%;\r\n\t}\r\n\t \r\n\t&lt;\/style&gt;\r\n\t \t\t&lt;meta charset=\"utf-8\" \/&gt;\r\n\t\t&lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, target-densitydpi=device-dpi\"\/&gt;\r\n\t\r\n\t&lt;title&gt;HTML Form&lt;\/title&gt;\r\n\t\r\n\t&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;form action= \"index.php\" method = \r\n\"post\"&gt;\r\nName: \r\n &lt;input type = \"text\" name = \"name\" required&gt;\r\n&lt;br&gt;&lt;br&gt;\r\nE-mail: \r\n&lt;input type = \"email\" name = \"email\" required&gt;\r\n&lt;br&gt;&lt;br&gt;\r\n&lt;select&gt;\r\n&lt;option value= Female&gt; Female &lt;\/option&gt;\r\n&lt;option value= Male&gt; Male &lt;\/option&gt;\r\n&lt;\/select&gt;&lt;br&gt;&lt;br&gt;\r\n\r\n&lt;select&gt;\r\n&lt;option value= Volvo&gt; Volvo &lt;\/option&gt;\r\n&lt;option value= Mercedes&gt; Mercedes &lt;\/option&gt;\r\n&lt;option value= Peaugot&gt; Peaugot &lt;\/option&gt;\r\n&lt;option value= Honda&gt; Honda &lt;\/option&gt;\r\n&lt;\/select&gt;&lt;br&gt;&lt;br&gt;\r\n\r\n&lt;input type=\"submit\" value=submit&gt;\r\n&lt;\/form&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p>HTML Drop-down list is created with the <code>&lt;select&gt;<\/code> tags, and each item in the list is created with the <code>option<\/code> tag ( line 32 ).<br \/>\nThe content between the opening <code>&lt; option &gt;<\/code> and closing <code>&lt; \/option &gt;<\/code> tags is what the browsers will display in a drop-down list. However, the value of the value attribute is what will be sent to the server when a form is submitted. If the value attribute is not specified or defined, the content of the option tag is sent to the server.<\/p>\n<h3>1.2 Handling List Data With PHP<\/h3>\n<p><span style=\"text-decoration: underline;\"><em>index1.php<\/em><\/span><\/p>\n<pre class=\"brush:php; highlight:[24,25,26,27,28]\">  \r\n&lt;!DOCTYPE html&gt; \r\n&lt;html lang=eng&gt;\r\n\t&lt;head&gt;\r\n\t&lt;style&gt;\r\n\thtml, body{\r\n\twidth: 100%;\r\n\theight: 100%;\r\n\tmargin: 0%;\r\n\tfont-family:\"helvetica\", \"verdana\",  \"calibri\", \"san serif\";\r\n\toverflow: hidden;\r\n\tpadding: 0%;\r\n\tborder: 0%;\r\n\t}\r\n\t \r\n\t&lt;\/style&gt;\r\n\t \t\t&lt;meta charset=\"utf-8\" \/&gt;\r\n\t\t&lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, target-densitydpi=device-dpi\"\/&gt;\r\n\t\r\n\t&lt;title&gt;HTML Form&lt;\/title&gt;\r\n\t\r\n\t&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;?php\r\nif(isset($_POST[\"submit\"])){\r\necho $_POST[\"gender\"].\"&lt;br&gt;\";\r\necho $_POST[\"cars\"].\"&lt;br&gt;\";\r\n}\r\nelse{\r\n?&gt;\r\n&lt;form action=\"index1.php\" method =\"post\"&gt;\r\n&lt;select name=gender&gt;\r\n&lt;option value= Female&gt; Female &lt;\/option&gt;\r\n&lt;option value= Male&gt; Male &lt;\/option&gt;\r\n&lt;\/select&gt;&lt;br&gt;&lt;br&gt;\r\n&lt;select name=cars&gt;\r\n&lt;option value= Volvo&gt; Volvo &lt;\/option&gt;\r\n&lt;option value= Mercedes&gt; Mercedes &lt;\/option&gt;\r\n&lt;option value= Peaugot&gt; Peaugot &lt;\/option&gt;\r\n&lt;option value= Honda&gt; Honda &lt;\/option&gt;\r\n&lt;\/select&gt;&lt;br&gt;&lt;br&gt;\r\n&lt;input type=\"submit\" value=submit name=submit&gt;\r\n&lt;\/form&gt;\r\n\r\n&lt;?php\r\n}\r\n?&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p>In the sample code above we simply check if the form has been submitted(line 24 to 28). If it has been submitted we echo the values selected in the list or else we echo a form containing the drop-down list.<br \/>\n<b>Note: <\/b> It\u2019s always a good idea to have a \u201cblank\u201d option as the first option in your select box. It forces the user to make a conscious selection from the box and avoids a situation where the user might skip over the box without meaning to. Of course, this will require validation.<\/p>\n<h3>1.3 Dealing With Multiple Fields<\/h3>\n<p>It is possible to create forms fields that send mutiple values rather than a single value. For example the list below sends mutiple values to the server.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>index2.php<\/em><\/span><\/p>\n<pre class=\"brush:php; highlight:[29, 34, 46, 53]\">  \r\n\r\n&lt;!DOCTYPE html&gt; \r\n&lt;html lang=eng&gt;\r\n\t&lt;head&gt;\r\n\t&lt;style&gt;\r\n\thtml, body{\r\n\twidth: 100%;\r\n\theight: 100%;\r\n\tmargin: 0%;\r\n\tfont-family: \"helvetica\", \"verdana\",  \"calibri\", \"san serif\";\r\n\toverflow: hidden;\r\n\tpadding: 0%;\r\n\tborder: 0%;\r\n\t}\r\n\t \r\n\t&lt;\/style&gt;\r\n\t \t\t&lt;meta charset=\"utf-8\" \/&gt;\r\n\t\t&lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, target-densitydpi=device-dpi\"\/&gt;\r\n\t\r\n\t&lt;title&gt; HTML Form &lt;\/title&gt;\r\n\t\r\n\t&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;?php\r\nif(isset($_POST[\"submit\"])){\r\necho \"&lt;p&gt;Your Selection Are: &lt;\/p&gt;\";\r\necho $_POST[\"gender\"] . \"&lt;br&gt;\";\r\nif(isset($_POST[\"cars\"])){\r\necho \"&lt;h3&gt;The Cars You Selected Are: &lt;\/h3&gt;\";\r\nforeach($_POST[\"cars\"] as $car)\r\necho $car .\"&lt;br&gt;\";\r\n}\r\nif(isset($_POST[\"name\"])){\r\necho \"&lt;h3&gt;The Names You Selected Are: &lt;\/h3&gt;\";\r\nforeach($_POST[\"name\"] as $name)\r\necho $name .\"&lt;br&gt;\";\r\n}\r\n\r\n}\r\nelse{\r\n?&gt;\r\n&lt;form action=\"index2.php\" method =\"post\"&gt;\r\n&lt;select name=gender&gt;\r\n&lt;option value= Female&gt; Female &lt;\/option&gt;\r\n&lt;option value= Male&gt; Male &lt;\/option&gt;\r\n&lt;\/select&gt;&lt;br&gt;&lt;br&gt;\r\n&lt;select name=cars[] multiple=\"mutiple\" size=\"3\"&gt;\r\n&lt;option value= Volvo&gt; Volvo &lt;\/option&gt;\r\n&lt;option value= Mercedes&gt; Mercedes &lt;\/option&gt;\r\n&lt;option value= Peaugot&gt; Peaugot &lt;\/option&gt;\r\n&lt;option value= Honda&gt; Honda &lt;\/option&gt;\r\n&lt;\/select&gt;&lt;br&gt;&lt;br&gt;\r\n\r\n&lt;select name=name[] multiple=\"mutiple\" size=\"3\"&gt;\r\n&lt;option value= Kelvin&gt; Kelvin &lt;\/option&gt;\r\n&lt;option value= John&gt; John &lt;\/option&gt;\r\n&lt;option value= Ken&gt; Ken &lt;\/option&gt;\r\n&lt;option value= Francis&gt; Francis &lt;\/option&gt;\r\n&lt;\/select&gt;&lt;br&gt;&lt;br&gt;\r\n\r\n&lt;input type= \"submit\" value= submit name= submit&gt;\r\n&lt;\/form&gt;\r\n\r\n&lt;?php\r\n}\r\n?&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p>Two square brackets are appended to the name of each select tag (line 46 and 53). The square bracket tells the PHP engine to expect multiple values for those fields and to create corresponding nested arrays within the relevant superglobal array ($_POST in this case).<br \/>\nThe script loops through each of the array elements in the nested array and echo there values on different lines.<br \/>\n<b> Note: <\/b> It is considered bad practise to trust user input without validating it. So you shouldn&#8217;t pass the values in <code>$_GET<\/code> and <code>$_POST<\/code> directly to <code>echo<\/code> or <code>print<\/code> for display in a webpage. A malicious user might be trying to break into the site. It is quite easy for a malicious user to submit form data to an unprotected site that could be used to gain access to other users credentials.<\/p>\n<h2>2. Summary<\/h2>\n<p>In this example we learnt about html forms, what are they and how to create them. We also learnt how to add select boxes and multi-select boxes to an HTML form, how to retrieve the input data and manipulate them.<\/p>\n<h2>3. Download the source code<\/h2>\n<div class=\"download\"><strong> Download <\/strong><br \/>\nYou can download the full source code of this example here: <strong><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/10\/phpdropdownexample.zip\">phpdropdownexample <\/a> <\/strong><\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this example we will learn how to handle data from a drop-down-list in HTML with PHP. For this example we will use: A computer with PHP&gt;= 5.5 installed notepad++ We will show you how to add select boxes and multi-select boxes to a form, how to retrieve the input data from them and how &hellip;<\/p>\n","protected":false},"author":164,"featured_media":930,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-14799","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>PHP Form Dropdown Example - Web Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"In this example we will learn how to handle data from a drop-down-list in HTML with PHP. For this example we will use: A computer with PHP&gt;= 5.5\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webcodegeeks.com\/php\/php-form-dropdown-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PHP Form Dropdown Example - Web Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"In this example we will learn how to handle data from a drop-down-list in HTML with PHP. For this example we will use: A computer with PHP&gt;= 5.5\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webcodegeeks.com\/php\/php-form-dropdown-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webcodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2016-10-03T13:15:45+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-01-09T08:26:41+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Olayemi Odunayo\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Olayemi Odunayo\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-form-dropdown-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-form-dropdown-example\/\"},\"author\":{\"name\":\"Olayemi Odunayo\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/417918d9b5811210265e8590509718b8\"},\"headline\":\"PHP Form Dropdown Example\",\"datePublished\":\"2016-10-03T13:15:45+00:00\",\"dateModified\":\"2018-01-09T08:26:41+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-form-dropdown-example\/\"},\"wordCount\":637,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-form-dropdown-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg\",\"articleSection\":[\"PHP\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webcodegeeks.com\/php\/php-form-dropdown-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-form-dropdown-example\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/php\/php-form-dropdown-example\/\",\"name\":\"PHP Form Dropdown Example - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-form-dropdown-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-form-dropdown-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg\",\"datePublished\":\"2016-10-03T13:15:45+00:00\",\"dateModified\":\"2018-01-09T08:26:41+00:00\",\"description\":\"In this example we will learn how to handle data from a drop-down-list in HTML with PHP. For this example we will use: A computer with PHP&gt;= 5.5\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-form-dropdown-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/php\/php-form-dropdown-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-form-dropdown-example\/#primaryimage\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-form-dropdown-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webcodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PHP\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/php\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"PHP Form Dropdown Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"name\":\"Web Code Geeks\",\"description\":\"Web Developers Resource Center\",\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webcodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webcodegeeks\",\"https:\/\/x.com\/webcodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/417918d9b5811210265e8590509718b8\",\"name\":\"Olayemi Odunayo\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/016b2a353262962fceecf5c274161cd9ef60fdf1593ec95e71d37f5fd9b444f6?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/016b2a353262962fceecf5c274161cd9ef60fdf1593ec95e71d37f5fd9b444f6?s=96&d=mm&r=g\",\"caption\":\"Olayemi Odunayo\"},\"description\":\"I am a programmer and web developer, who has experience in developing websites and writing desktop and mobile applications. I have worked with both schematic and schemaless databases. I am also familiar with third party API and working with cloud servers. I do programming on the client side with Java, JavaScript, html, Ajax and CSS while I use PHP for server side programming.\",\"sameAs\":[\"https:\/\/www.webcodegeeks.com\/\"],\"url\":\"https:\/\/www.webcodegeeks.com\/author\/olayemi-odunayo\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"PHP Form Dropdown Example - Web Code Geeks - 2026","description":"In this example we will learn how to handle data from a drop-down-list in HTML with PHP. For this example we will use: A computer with PHP&gt;= 5.5","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.webcodegeeks.com\/php\/php-form-dropdown-example\/","og_locale":"en_US","og_type":"article","og_title":"PHP Form Dropdown Example - Web Code Geeks - 2026","og_description":"In this example we will learn how to handle data from a drop-down-list in HTML with PHP. For this example we will use: A computer with PHP&gt;= 5.5","og_url":"https:\/\/www.webcodegeeks.com\/php\/php-form-dropdown-example\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_published_time":"2016-10-03T13:15:45+00:00","article_modified_time":"2018-01-09T08:26:41+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg","type":"image\/jpeg"}],"author":"Olayemi Odunayo","twitter_card":"summary_large_image","twitter_creator":"@webcodegeeks","twitter_site":"@webcodegeeks","twitter_misc":{"Written by":"Olayemi Odunayo","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webcodegeeks.com\/php\/php-form-dropdown-example\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/php\/php-form-dropdown-example\/"},"author":{"name":"Olayemi Odunayo","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/417918d9b5811210265e8590509718b8"},"headline":"PHP Form Dropdown Example","datePublished":"2016-10-03T13:15:45+00:00","dateModified":"2018-01-09T08:26:41+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/php\/php-form-dropdown-example\/"},"wordCount":637,"commentCount":0,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/php\/php-form-dropdown-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg","articleSection":["PHP"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webcodegeeks.com\/php\/php-form-dropdown-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/php\/php-form-dropdown-example\/","url":"https:\/\/www.webcodegeeks.com\/php\/php-form-dropdown-example\/","name":"PHP Form Dropdown Example - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/php\/php-form-dropdown-example\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/php\/php-form-dropdown-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg","datePublished":"2016-10-03T13:15:45+00:00","dateModified":"2018-01-09T08:26:41+00:00","description":"In this example we will learn how to handle data from a drop-down-list in HTML with PHP. For this example we will use: A computer with PHP&gt;= 5.5","breadcrumb":{"@id":"https:\/\/www.webcodegeeks.com\/php\/php-form-dropdown-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/php\/php-form-dropdown-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/php\/php-form-dropdown-example\/#primaryimage","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.webcodegeeks.com\/php\/php-form-dropdown-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webcodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"PHP","item":"https:\/\/www.webcodegeeks.com\/category\/php\/"},{"@type":"ListItem","position":3,"name":"PHP Form Dropdown Example"}]},{"@type":"WebSite","@id":"https:\/\/www.webcodegeeks.com\/#website","url":"https:\/\/www.webcodegeeks.com\/","name":"Web Code Geeks","description":"Web Developers Resource Center","publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webcodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webcodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.webcodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webcodegeeks","https:\/\/x.com\/webcodegeeks"]},{"@type":"Person","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/417918d9b5811210265e8590509718b8","name":"Olayemi Odunayo","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/016b2a353262962fceecf5c274161cd9ef60fdf1593ec95e71d37f5fd9b444f6?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/016b2a353262962fceecf5c274161cd9ef60fdf1593ec95e71d37f5fd9b444f6?s=96&d=mm&r=g","caption":"Olayemi Odunayo"},"description":"I am a programmer and web developer, who has experience in developing websites and writing desktop and mobile applications. I have worked with both schematic and schemaless databases. I am also familiar with third party API and working with cloud servers. I do programming on the client side with Java, JavaScript, html, Ajax and CSS while I use PHP for server side programming.","sameAs":["https:\/\/www.webcodegeeks.com\/"],"url":"https:\/\/www.webcodegeeks.com\/author\/olayemi-odunayo\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/14799","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/users\/164"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/comments?post=14799"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/14799\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media\/930"}],"wp:attachment":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media?parent=14799"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=14799"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=14799"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}