Advertisement
gsmashik

get-multiple-checkbox-value-in-php

Sep 14th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. <form method="post">
  2.  
  3. <table border="1">
  4.  
  5. <tr>
  6.  
  7. <td>Chocolate</td>
  8.  
  9.  
  10. <td><input type="checkbox" value="Chocolate" name="chklist[]"/></td>
  11.  
  12. </tr>
  13.  
  14. <tr>
  15.  
  16.  
  17. <td>Coffee</td>
  18.  
  19. <td><input type="checkbox" value="Coffee" name="chklist[]"/></td>
  20.  
  21. </tr>
  22.  
  23. <tr>
  24.  
  25. <td>Tea</td>
  26.  
  27. <td><input type="checkbox" value="Tea" name="chklist[]"/></td>
  28.  
  29. </tr>
  30.  
  31. <tr>
  32.  
  33. <td>Buiscuit</td>
  34.  
  35. <td><input type="checkbox" value="Buiscuit" name="chklist[]"/></td>
  36.  
  37. </tr>
  38.  
  39. <tr>
  40.  
  41. <td align="center" colspan="2"><input type="submit" value="Show my Items" name="save"/></td>
  42.  
  43. </tr>
  44.  
  45. </table>
  46.  
  47. </form>
  48.  
  49.  
  50.  
  51. <?php
  52.  
  53. extract($_POST);
  54.  
  55. if(isset($save))
  56.  
  57. {
  58.  
  59. if(!empty($chklist))
  60.  
  61. {
  62.  
  63. echo "<h3>You have selected these items :</h3>";
  64.  
  65. echo "<ol type='A'>";
  66.  
  67. foreach($chklist as $val)
  68.  
  69. {
  70.  
  71. echo "<li>";
  72.  
  73. echo $val;
  74.  
  75. echo "</li>";
  76.  
  77. }
  78.  
  79. echo "</ol>";
  80.  
  81. }
  82.  
  83. else
  84.  
  85. {
  86.  
  87. echo "<font color='red'>pls select your items</font>";
  88.  
  89. }
  90.  
  91. }
  92.  
  93. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement