Check for checkbox’s [PHP]

To check which checkbox is selected, or if both are selected, in PHP

<input type="checkbox" name="coupons[]" value="1" >
<input type="checkbox" name="coupons[]" value="2" >

checker in php

if (isset($_POST['Submit'])) {
$state=$_POST['coupons'];
foreach ($state as $statename)
{
$x = $statename;
$ugh .= $x;
}

if 1 is selected, result will be 1
if 2 is selected result will be 2
if both are selected, result will be 12

go forward using if($ugh == ‘12′){ } etc


No Comments to “Check for checkbox’s [PHP]”  

  1. No Comments

Leave a Reply