Get values of checked Multiple checkbox in PHP – PHP Tutorial

Today we are going to learn about multiple checkbox in php form. How to use this type of multiple checkboxes in PHP form, How to post or pass multiple checkbox values in php all the things cover in this article. Basically in this example tutorial we are creating a form which content multiple checkbox and after form submit we are checking that which checkbox are checked. The main tricks to get value of multiple checked checkboxes, name attribute in HTML input type=”checkbox” tag must be initialize with an array, to do this write [ ] at the end of it’s name. In our example it is defined as name=”check_items[]”. After form submit we can easily Get Multiple Checkbox Values in PHP with $_POST[“your array field name”]. So in this simple way we can handle multiple checkboxes value in a form.

Take a quick look at multiple checkbox in php example live demo to understand how to post multiple checkbox value in php array or how to pass multiple checkbox values in php. From my previous tutorial you can get a knowledge about the php get post method. Also you can free download this multiple checkbox in php example script from here and can try in your localhost or live server where you want to do.

Multiple checkbox in PHP Example

Step 1:Create php form with multiple checkboxes

<form class="form-horizontal" method="post" id="getform">                            
 <input type="checkbox" name="check_items[]" value="Demo">Demo<br/>
 <input type="checkbox" name="check_items[]" value="Webtools">Webtools<br/>
<input type="checkbox" name="check_items[]" value="Web Programming">Web Programming<br/>
<input type="checkbox" name="check_items[]" value="PHP">PHP<br/>
<input type="submit" class="btn btn-primary btn-lg" name="submit" value="Submit"/>

Step 2: Access post values of multiple checkboxes after form submit.

As explained earlier, how can we submit a form in php in PHP get post methods. Just go through once you can get a clear idea about php form submit. In this example we are using php post method to handle or to access multiple checked checkbox values after form submit. After form submit the following code will generate our output result.

if(isset($_POST['submit'])){//PHP script after form submit
if(!empty($_POST['check_items'])){//check atleast one checkbox checked or not
// Loop to store and display values of individual checked checkbox.
echo "Selected ".$count." Items:"."</br>";
	foreach($_POST['check_items'] as $selected_checkitem){
		echo $selected_checkitem."</br>";

In our example, there is a form contains some checkboxes, User checks them and when he/she hits submit button, multiple values of checkboxes will be display.

Watch our live demo or download our codes to use it.

In this way we can use PHP forms with multiple checkboxes.$_post is use to retrieve the submitted checked values and display. So basically if your query about php multiple checkbox i think this PHP tutorial example will be very helpful for you. So, don’t miss to learn and practice yourself. Thanks for watching this tutorial about get values of multiple checkbox in php . You can try yourself and share with your friends. I will share some useful script in PHP as well as some tips and tricks in PHP programming. Viewers can subscribe our newsletter to get all the updates about web programming. Share and likes will be appreciated also help to evaluate our self.

If you need any help regarding the same please feel free to comment we love to help you.

4 responses to “Get values of checked Multiple checkbox in PHP – PHP Tutorial”

  1. Leia Merila says:

    This is the right blog for anyone who wants to find out about this topic. Great stuff, just great!

  2. Anonymous says:

    Can you please forward me the code for this script or please enlighten me in detail concerning this script?

  3. jig says:

    it wanna like a checkbox and it will display a value of it wihout submit button just print it and when uncheck it will remove also..without jquiry can you send that type of code..

Leave a Reply

Your email address will not be published. Required fields are marked *