How to pass multiple checkbox value on form submit

This tutorial we are implement pass multiple checkbox value on submit form. there are require in many signup form for select user for newsletter category and many other forms. So let’s have start with create HTML form

Create HTML form and make file call index.php

<form action="" method="post">
<label>Select your programming language:</label><br/>
<input type="checkbox" name="language[]" value="PHP"><label>PHP</label><br/>
<input type="checkbox" name="language[]" value="JAVA"><label>JAVA</label><br/>
<input type="checkbox" name="language[]" value="Laravel"><label>Laravel</label><br/>
<input type="checkbox" name="language[]" value="WordPress"><label>WordPress</label><br/>
<input type="checkbox" name="language[]" value="Node.js"><label>Node.js</label><br/><br/>
<input type="submit" name="submit" Value="Submit"/>

on submit HTML form pass checkbox value

			foreach($_POST['language'] as $key=>$value){
			echo "You are selected ".implode(",",$selected);

We can store value in array based on user selected. we use implode function to make it as string. you can do as per your needs.

Final Output

pass multiple checkbox value on form submit

Leave a Reply