Home >>PHP Programs >Get Multiple checkbox value in PHP
<?php extract($_POST); if(isset($save)) { if(!empty($chklist)) { echo "<h3>You have selected these items :</h3>"; echo "<ol type='A'>"; foreach($chklist as $val) { echo "<li>"; echo $val; echo "</li>"; } echo "</ol>"; } else { echo "<font color='red'>pls select your items</font>"; } } ?>
<form method="post"> <table border="1"> <tr> <td>Chocolate</td> <td><input type="checkbox" value="Chocolate" name="chklist[]"/></td> </tr> <tr> <td>Coffee</td> <td><input type="checkbox" value="Coffee" name="chklist[]"/></td> </tr> <tr> <td>Tea</td> <td><input type="checkbox" value="Tea" name="chklist[]"/></td> </tr> <tr> <td>Buiscuit</td> <td><input type="checkbox" value="Buiscuit" name="chklist[]"/></td> </tr> <tr> <td align="center" colspan="2"><input type="submit" value="Show my Items" name="save"/></td> </tr> </table> </form>