How to get checkbox selected value in php

How to retrieve check box marked data value using php code.

In this tutorial we are creating two checkbox using input type checkbox with check box array. Now we are creating a submit button and after that we are showing check box selected value on screen. So here is the complete step by step tutorial for How to get checkbox selected value in php.

android-project-download-code-button

How to get checkbox selected value in php.

Code for get-checkbox-selected-value.php file.

 <!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>How to get checkbox selected value in php</title>
</head>

<body>

<h2>How to get checkbox selected value in php.</h2>
 <form method="post" action="">
 <input type="checkbox" name="check[]" value="Android"><label>Android</label><br/>
 <input type="checkbox" name="check[]" value="PHP"><label>PHP</label><br/>
 <input type="submit" name="submit" Value="submit">
 </form>
</br>

<?php
if (isset($_POST['submit']))
{
 $chkbox = $_POST['check'];
 $i = 0;
 While($i < sizeof($chkbox))
 {
 
 echo "CheckBox selected Value = " . $chkbox[$i] . '</br>';
 
 $i++;
 }
 
 }
 
 ?>

</body>
</html>

Screenshot:

How to get checkbox selected value in php

Click here to download How to get checkbox selected value in php project file with source code.