Answers for "php checkbox checked"

17

html checkbox

<!--
  You can also group multiple checkboxes by giving them the same "name".
  When posted to PHP, all the checked boxes' values will appear in the
  $_POST array under an index with the same name as your checkboxes.

  E.g. if we check "bananas" and "apples" below and post the form then
  our $_POST array will look something like this:
  ['fruit' => ['bananas', 'apples']]
-->
<form>
  <label>
    <span>Bananas</span>
    <input type="checkbox" name="fruit[]" value="bananas">
  </label>
  
  <label>
    <span>Apples</span>
    <input type="checkbox" name="fruit[]" value="apples">
  </label>
  
  <label>
    <span>Grapes</span>
    <input type="checkbox" name="fruit[]" value="grapes">
  </label>
  
  <button type="submit">Submit</button>
</form>
Posted by: Guest on April-08-2020
0

how to check for checked checkboxes in php

htmlCopy# html 5
<form action="index.php" method="post" >
<input type="checkbox" name="test1" value="value1"> Option 1
<input type="checkbox" name="test2" value="value2"> Option 2
<input type="submit" value="Submit"> 
</form>

   #php 7.x
<?php
if(isset($_POST['test1'])){
    echo "checked value1"."<br>";
}
if(isset($_POST['test2'])){
    echo "checked value2";
}
?>
Posted by: Guest on September-21-2021
-1

how to display checked checkbox value in php

<td align="center"><h4>Portrait Packages</h4>
        <!--Please select the package(s) you wish to purchase.--></td>
        
          
          <td>
          	<input type="checkbox" name="package[]" value="bronze"> Bronze - $62.95<br>
            <input type="checkbox" name="package[]" value="silver"> Silver - $65.95<br>
          	<input type="checkbox" name="package[]" value="gold"> Gold - $67.95<br>
            <input type="checkbox" name="package[]" value="platinum"> Platinum - $69.95<br>
            <input type="checkbox" name="package[]" value="unbelievable"> Unbelievable - $83.95<br>
          	<input type="checkbox" name="package[]" value="astonishing"> Astonishing - $86.95<br>

          </td>
        </tr>
         <tr>
        <td align="center"><h4>Additional Prints with Package Purchase</h4>
 </td>
        
          
          <td>
          	<input type="checkbox" name="print[]" value="three_by_five"> Four 3x5's - $16.00<br>
            <input type="checkbox" name="print[]" value="five_by_seven"> Two 5x7's - $16.00<br>
          	<input type="checkbox" name="print[]" value="eight_by_ten"> One 8x10 - $16.00<br>
            <input type="checkbox" name="print[]" value="sixteen_wallets"> 16 Wallets - $16.00<br>
            <input type="checkbox" name="print[]" value="twentyfour_wallets"> 24 Wallets - $30.95<br>
          	<input type="checkbox" name="print[]" value="ten_by_thirteen"> One 10x13 - $21.00<br>

          </td>
        </tr>
        <tr>
        <td align="center"><h4>Additional Prints without Package Purchase</h4>
 </td>
         <td>
          	<input type="checkbox" name="print_nopack[]" value="three_by_five_nopack"> Four 3x5's - $40.95<br>

            <input type="checkbox" name="print_nopack[]" value="five_by_seven_nopack"> Two 5x7's - $44.95<br>
          	<input type="checkbox" name="print_nopack[]" value="eight_by_ten_nopack"> One 8x10 - $46.95<br>
            <input type="checkbox" name="print_nopack[]" value="sixteen_wallets_nopack"> 16 Wallets - $25.95<br>
            <input type="checkbox" name="print_nopack[]" value="twentyfour_wallets_nopack"> 24 Wallets - $30.95<br>
          	<input type="checkbox" name="print_nopack[]" value="ten_by_thirteen_nopack"> One 10x13 - $50.95<br>

          </td>
        </tr>
        <tr>
          <td align="right" valign="top"><label for="message">Special Instructions:</label>  </td>
          <td><textarea name="message" id="message" cols="50" rows="3"></textarea></td>
        </tr>
Posted by: Guest on November-05-2020

Browse Popular Code Answers by Language