post checkbox value post checkbox value php php

post checkbox value


There are many links that lets you know how to handle post values from checkboxes in php.Look at this link: http://www.html-form-guide.com/php-form/php-form-checkbox.html

Single check box

HTML code:

<form action="checkbox-form.php" method="post">    Do you need wheelchair access?    <input type="checkbox" name="formWheelchair" value="Yes" />    <input type="submit" name="formSubmit" value="Submit" /></form>

PHP Code:

<?phpif (isset($_POST['formWheelchair']) && $_POST['formWheelchair'] == 'Yes') {    echo "Need wheelchair access.";}else{    echo "Do not Need wheelchair access.";}    ?>

Check box group

<form action="checkbox-form.php" method="post">    Which buildings do you want access to?<br />    <input type="checkbox" name="formDoor[]" value="A" />Acorn Building<br />    <input type="checkbox" name="formDoor[]" value="B" />Brown Hall<br />    <input type="checkbox" name="formDoor[]" value="C" />Carnegie Complex<br />    <input type="checkbox" name="formDoor[]" value="D" />Drake Commons<br />    <input type="checkbox" name="formDoor[]" value="E" />Elliot House    <input type="submit" name="formSubmit" value="Submit" /> /form><?php  $aDoor = $_POST['formDoor'];  if(empty($aDoor))   {    echo("You didn't select any buildings.");  }   else  {    $N = count($aDoor);    echo("You selected $N door(s): ");    for($i=0; $i < $N; $i++)    {      echo($aDoor[$i] . " ");    }  }?>


in normal time, checkboxes return an on/off value.

you can verify it with this code:

<form action method="POST">      <input type="checkbox" name="hello"/></form><?phpif(isset($_POST['hello'])) echo('<p>'.$_POST['hello'].'</p>');?>

this will return

<p>off</p>

or

<p>on</p>


You should use

<input type="submit" value="submit" />

inside your form.

and add action into your form tag for example:

<form action="booking.php" method="post">

It's post your form into action which you choose.

From php you can get this value by

$_POST['booking-check'];