{"id":14255,"date":"2016-08-02T16:15:34","date_gmt":"2016-08-02T13:15:34","guid":{"rendered":"http:\/\/www.webcodegeeks.com\/?p=14255"},"modified":"2018-01-09T10:47:19","modified_gmt":"2018-01-09T08:47:19","slug":"php-radio-button-example","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/php\/php-radio-button-example\/","title":{"rendered":"PHP Radio Button Example"},"content":{"rendered":"<p>Radio buttons are one of the basic HTML forms elements, similar to checkboxes but restricting the selection to an only choice. The most typical examples of this are the yes\/no or gender questions, or any other type of quizzes. In this tutorial we will see how to deal with these with PHP.<\/p>\n<p>For this example, we will use:<\/p>\n<ul>\n<li>Linux Mint (17.03) as Operating System.<\/li>\n<li>Apache HTTP server (2.4.7).<\/li>\n<li>PHP (5.5.9).<\/li>\n<\/ul>\n<div class=\"tip\"><strong>Tip<\/strong><br \/>\nYou may skip environment preparation and jump directly to the <a href=\"#section_2\"><strong>beginning of the example<\/strong><\/a> below.<\/div>\n<p>[ulp id=&#8217;8njY7i2QRy6sg8pg&#8217;]<\/p>\n<h2>1. Preparing the environment<\/h2>\n<p>Below, commands to install Apache and PHP are shown:<\/p>\n<pre class=\"brush:bash\">sudo apt-get update\r\nsudo apt-get install apache2 php5 libapache2-mod-php5\r\nsudo service apache2 restart<\/pre>\n<p><strong>Note:<\/strong> if you want to use Windows, installing XAMPP is the fastest and easiest way to install a complete web server that meets the prerequisites.<\/p>\n<h2 id=\"section_2\">2. HTML form<\/h2>\n<p>Before the PHP part, we first have to understand how radio inputs work. For this, let&#8217;s create a simple form like the following:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>form.html<\/em><\/span><\/p>\n<pre class=\"brush:html\">&lt;!DOCTYPE html&gt;\r\n&lt;head&gt;\r\n\u00a0\u00a0 \u00a0&lt;meta charset=\"UTF-8\"&gt;\r\n\u00a0\u00a0 \u00a0&lt;title&gt;HTML form&lt;\/title&gt;\r\n\u00a0\u00a0 \u00a0&lt;style&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0html {\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0width: 30%;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0}\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0.form-input {\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0margin-bottom: 20px;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0}\r\n\u00a0\u00a0 \u00a0&lt;\/style&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n\u00a0\u00a0 \u00a0&lt;form method=\"GET\" action=\"process.php\"&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&lt;div class=\"form-input\"&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&lt;label for=\"name\"&gt;Your name&lt;\/label&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&lt;input type=\"text\" name=\"name\" id=\"name\" required&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&lt;\/div&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&lt;div class=\"form-input\"&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&lt;fieldset&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&lt;legend&gt;Gender&lt;\/legend&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&lt;div&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&lt;input type=\"radio\" name=\"gender\" id=\"male\" value=\"Male\" required&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&lt;label for=\"male\"&gt;Male&lt;\/label&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&lt;\/div&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&lt;div&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&lt;input type=\"radio\" name=\"gender\" id=\"female\" value=\"Female\"&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&lt;label for=\"female\"&gt;Female&lt;\/label&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&lt;\/div&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&lt;\/fieldset&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&lt;\/div&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&lt;div class=\"form-input\"&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&lt;fieldset&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&lt;legend&gt;Favourite programming language&lt;\/legend&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&lt;div&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&lt;input type=\"radio\" name=\"programming-language\" id=\"php\" value=\"PHP\" required&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&lt;label for=\"php\"&gt;PHP&lt;\/label&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&lt;\/div&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&lt;div&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&lt;input type=\"radio\" name=\"programming-language\" id=\"java\" value=\"Java\"&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&lt;label for=\"java\"&gt;Java&lt;\/label&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&lt;\/div&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&lt;div&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&lt;input type=\"radio\" name=\"programming-language\" id=\"c\" value=\"C\"&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&lt;label for=\"c\"&gt;C&lt;\/label&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&lt;\/div&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&lt;div&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&lt;input type=\"radio\" name=\"programming-language\" id=\"other\" value=\"Other\"&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&lt;label for=\"other\"&gt;Other&lt;\/label&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&lt;\/div&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&lt;\/fieldset&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&lt;\/div&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&lt;div class=\"form-input\"&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&lt;input type=\"submit\" value=\"Submit\"&gt;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0&lt;\/div&gt;\r\n\u00a0\u00a0 \u00a0&lt;\/form&gt;\r\n&lt;\/body&gt;\r\n\r\n&lt;\/html&gt;<\/pre>\n<p>For which the browser will generate the following rendering:<\/p>\n<figure style=\"width: 414px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/07\/Example-form.jpg\" width=\"414\" height=\"358\" \/><figcaption class=\"wp-caption-text\">Example form.<\/figcaption><\/figure>\n<p>Even if you probably already are familiar to forms with radio buttons, there are a couple of things we have to mention:<\/p>\n<ul>\n<li>Each &#8220;radio group&#8221; is formed with the radio buttons that have the same <code>name<\/code> attribute value.<\/li>\n<li>If a radio group&#8217;s button is required, is enough to add the <code>required<\/code> attribute only to one of the buttons of the group.<\/li>\n<\/ul>\n<h2>3. Form handling<\/h2>\n<p>Handling forms with radio buttons does not differ in any way from other forms.<\/p>\n<p>We have set the form method to <code>GET<\/code> to see how the data is submitted. This is an example of the data generated for a submission:<\/p>\n<pre class=\"brush:html\">process.php?name=Julen&amp;gender=Male&amp;programming-language=PHP<\/pre>\n<p>That is, the <code>value<\/code> of the selected radio button is set to the <code>name<\/code> of the group it belongs to.<code><\/code><\/p>\n<p>Let&#8217;s see how to process this form with a PHP script.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>process.php<\/em><\/span><\/p>\n<pre class=\"brush:php;highlight:[41,42]\">&lt;?php\r\n\r\n\/**\r\n\u00a0* Checks if the given parameters are set. If one of the specified parameters\r\n\u00a0* is not set, die() is called.\r\n\u00a0*\r\n\u00a0* @param $parameters The parameters to check.\r\n\u00a0*\/\r\nfunction checkGETParametersOrDie($parameters) {\r\n\u00a0\u00a0 \u00a0foreach ($parameters as $parameter) {\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0isset($_GET[$parameter]) || die(\"'$parameter' parameter must be set.\");\r\n\u00a0\u00a0 \u00a0}\r\n}\r\n\r\n\/**\r\n\u00a0* Prints the submitted data.\r\n\u00a0*\r\n\u00a0* @param array $data The form data, with $name =&gt; $value format.\r\n\u00a0*\/\r\nfunction printData($data) {\r\n\r\n\u00a0\u00a0 \u00a0echo 'You have submitted the form with the following data:&lt;br&gt;';\r\n\u00a0\u00a0 \u00a0echo '&lt;ul&gt;';\r\n\r\n\u00a0\u00a0 \u00a0foreach ($data as $name =&gt; $value) {\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0echo \"&lt;li&gt;$name: &lt;b&gt;$value&lt;\/b&gt;&lt;\/li&gt;\";\r\n\u00a0\u00a0 \u00a0}\r\n\r\n\u00a0\u00a0 \u00a0echo '&lt;\/ul&gt;';\r\n}\r\n\r\n\/\/ Flow starts here.\r\n\r\ncheckGETParametersOrDie([\r\n\u00a0\u00a0 \u00a0'name',\r\n\u00a0\u00a0 \u00a0'gender',\r\n\u00a0\u00a0 \u00a0'programming-language'\r\n]);\r\n\r\n$name = $_GET['name'];\r\n$gender = $_GET['gender'];\r\n$programmingLanguage = $_GET['programming-language'];\r\n\r\nprintData([\r\n\u00a0\u00a0 \u00a0'Name' =&gt; $name,\r\n\u00a0\u00a0 \u00a0'Gender' =&gt; $gender,\r\n\u00a0\u00a0 \u00a0'Favourite programming language' =&gt; $programmingLanguage\r\n]);<\/pre>\n<p>As you can see, the way of retrieving the data of radio buttons is the same as with other input types (lines 41, 42).<\/p>\n<p>So, for the previous <code>group<\/code> data, the generated output would be the following:<\/p>\n<blockquote><p>You have submitted the form with the following data:<\/p>\n<ul>\n<li>Name: <b>Julen<\/b><\/li>\n<li>Gender: <b>Male<\/b><\/li>\n<li>Favourite programming language: <b>PHP<\/b><\/li>\n<\/ul>\n<\/blockquote>\n<h2>4. Generating radio button structures dynamically<\/h2>\n<p>It&#8217;s worth mentioning how to generate radio button structures dynamically with PHP. This can be achieved with a simple function that parses a <code>$group =&gt; $values<\/code> array for generating the radio buttons, like with the following:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>generate_radiobuttons.php<\/em><\/span><\/p>\n<pre class=\"brush:php\">&lt;?php\r\n\r\n\/**\r\n\u00a0* Generates radio buttons groups HTML, for group =&gt; values structures, wrapping\r\n\u00a0* each group in a fieldset.\r\n\u00a0*\r\n\u00a0* @param array $data The data to create the radio buttons for.\r\n\u00a0* @return array The generated radio buttons.\r\n\u00a0*\/\r\nfunction generateRadioButtons($data) {\r\n\u00a0\u00a0 \u00a0$radioButtons = '';\r\n\r\n\u00a0\u00a0 \u00a0foreach ($data as $group =&gt; $values) {\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0$radioButtons .= '&lt;fieldset&gt;';\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0$radioButtons .= \"&lt;legend&gt;$group&lt;\/legend&gt;\";\r\n\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0foreach ($values as $value) {\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0$radioButtons .= '&lt;div&gt;';\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0$radioButtons .= \"&lt;label for='$value'&gt;$value&lt;\/label&gt;\";\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0$radioButtons .= \"&lt;input type='radio' name='$group' id='$value' value='$value'&gt;\";\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0$radioButtons .= '&lt;\/div&gt;';\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0}\r\n\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0$radioButtons .= '&lt;\/fieldset&gt;';\r\n\u00a0\u00a0 \u00a0}\r\n\r\n\u00a0\u00a0 \u00a0return $radioButtons;\r\n}<\/pre>\n<p>Grouping each radio group in a fieldset, as we have done in the example of the section 2.<\/p>\n<p>The following input for the function would generate the same radio groups that we have generated for the previous example:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>generate_radiobuttons.php<\/em><\/span><\/p>\n<pre class=\"brush:php\">&lt;?php\r\n\r\n\/\/ ...\r\n\r\n$genderButtons = [\r\n\u00a0\u00a0 \u00a0'Gender' =&gt; [\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0'Male',\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0'Female'\r\n\u00a0\u00a0 \u00a0]\r\n];\r\n\r\n$programmingLanguageButtons = [\r\n\u00a0\u00a0 \u00a0'Language' =&gt; [\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0'PHP',\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0'Java',\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0'Other'\r\n\u00a0\u00a0 \u00a0]\r\n];\r\n\r\n$radioButtons = generateRadioButtons($genderButtons + $programmingLanguageButtons);\r\n\r\necho $radioButtons;\r\n\r\necho 'Generated HTML code:&lt;br&gt;';\r\necho \"&lt;xmp&gt;$radioButtons&lt;\/xmp&gt;\";<\/pre>\n<p>Generating the same output we have seen in section 2.<\/p>\n<h2>5. Summary<\/h2>\n<p>In this example we have seen how to deal with radio buttons with PHP, which is actually the same as with any other HTML form elements. Apart from that, we have also seen how to generate radio buttons groups dynamically with a simple function, to generate dynamic forms; or maybe to make easier the process of generating a static, generating the HTML code for the radio groups.<\/p>\n<h2>6. Download the source code<\/h2>\n<p>This was an example of radio buttons with PHP.<\/p>\n<div class=\"download\"><strong>Download<\/strong><br \/>\nYou can download the full source code of this example here: <a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/07\/PHPRadioButtonExample.zip\"><strong>PHPRadioButtonExample<\/strong><\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Radio buttons are one of the basic HTML forms elements, similar to checkboxes but restricting the selection to an only choice. The most typical examples of this are the yes\/no or gender questions, or any other type of quizzes. In this tutorial we will see how to deal with these with PHP. For this example, &hellip;<\/p>\n","protected":false},"author":160,"featured_media":930,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[176,216],"class_list":["post-14255","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php","tag-form","tag-radio"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>PHP Radio Button Example - Web Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"Radio buttons are one of the basic HTML forms elements, similar to checkboxes but restricting the selection to an only choice. The most typical examples\" \/>\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-radio-button-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PHP Radio Button Example - Web Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"Radio buttons are one of the basic HTML forms elements, similar to checkboxes but restricting the selection to an only choice. The most typical examples\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webcodegeeks.com\/php\/php-radio-button-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-08-02T13:15:34+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-01-09T08:47:19+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=\"Toni\" \/>\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=\"Toni\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 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-radio-button-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-radio-button-example\/\"},\"author\":{\"name\":\"Toni\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/54a7be647b0b871cff41cbf3d2a95966\"},\"headline\":\"PHP Radio Button Example\",\"datePublished\":\"2016-08-02T13:15:34+00:00\",\"dateModified\":\"2018-01-09T08:47:19+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-radio-button-example\/\"},\"wordCount\":546,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-radio-button-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg\",\"keywords\":[\"form\",\"radio\"],\"articleSection\":[\"PHP\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webcodegeeks.com\/php\/php-radio-button-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-radio-button-example\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/php\/php-radio-button-example\/\",\"name\":\"PHP Radio Button Example - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-radio-button-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-radio-button-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg\",\"datePublished\":\"2016-08-02T13:15:34+00:00\",\"dateModified\":\"2018-01-09T08:47:19+00:00\",\"description\":\"Radio buttons are one of the basic HTML forms elements, similar to checkboxes but restricting the selection to an only choice. The most typical examples\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-radio-button-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/php\/php-radio-button-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-radio-button-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-radio-button-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 Radio Button 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\/54a7be647b0b871cff41cbf3d2a95966\",\"name\":\"Toni\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/21c1661474c78b4757355b8beef9ab1d14f490ee3a3e67392f4e618d36643d4c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/21c1661474c78b4757355b8beef9ab1d14f490ee3a3e67392f4e618d36643d4c?s=96&d=mm&r=g\",\"caption\":\"Toni\"},\"url\":\"https:\/\/www.webcodegeeks.com\/author\/julen-pardo\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"PHP Radio Button Example - Web Code Geeks - 2026","description":"Radio buttons are one of the basic HTML forms elements, similar to checkboxes but restricting the selection to an only choice. The most typical examples","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-radio-button-example\/","og_locale":"en_US","og_type":"article","og_title":"PHP Radio Button Example - Web Code Geeks - 2026","og_description":"Radio buttons are one of the basic HTML forms elements, similar to checkboxes but restricting the selection to an only choice. The most typical examples","og_url":"https:\/\/www.webcodegeeks.com\/php\/php-radio-button-example\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_published_time":"2016-08-02T13:15:34+00:00","article_modified_time":"2018-01-09T08:47:19+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":"Toni","twitter_card":"summary_large_image","twitter_creator":"@webcodegeeks","twitter_site":"@webcodegeeks","twitter_misc":{"Written by":"Toni","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webcodegeeks.com\/php\/php-radio-button-example\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/php\/php-radio-button-example\/"},"author":{"name":"Toni","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/54a7be647b0b871cff41cbf3d2a95966"},"headline":"PHP Radio Button Example","datePublished":"2016-08-02T13:15:34+00:00","dateModified":"2018-01-09T08:47:19+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/php\/php-radio-button-example\/"},"wordCount":546,"commentCount":0,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/php\/php-radio-button-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg","keywords":["form","radio"],"articleSection":["PHP"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webcodegeeks.com\/php\/php-radio-button-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/php\/php-radio-button-example\/","url":"https:\/\/www.webcodegeeks.com\/php\/php-radio-button-example\/","name":"PHP Radio Button Example - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/php\/php-radio-button-example\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/php\/php-radio-button-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg","datePublished":"2016-08-02T13:15:34+00:00","dateModified":"2018-01-09T08:47:19+00:00","description":"Radio buttons are one of the basic HTML forms elements, similar to checkboxes but restricting the selection to an only choice. The most typical examples","breadcrumb":{"@id":"https:\/\/www.webcodegeeks.com\/php\/php-radio-button-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/php\/php-radio-button-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/php\/php-radio-button-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-radio-button-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 Radio Button 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\/54a7be647b0b871cff41cbf3d2a95966","name":"Toni","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/21c1661474c78b4757355b8beef9ab1d14f490ee3a3e67392f4e618d36643d4c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/21c1661474c78b4757355b8beef9ab1d14f490ee3a3e67392f4e618d36643d4c?s=96&d=mm&r=g","caption":"Toni"},"url":"https:\/\/www.webcodegeeks.com\/author\/julen-pardo\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/14255","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\/160"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/comments?post=14255"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/14255\/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=14255"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=14255"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=14255"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}