How to Get/Display Multiple checkbox selected values in php on same page

How to show Multiple chekbox or single checkbox value on same php page above-below the checkbox.

In this tutorial we are creating multiple checkbox with submit button and transfer the checkbox checked values on same page so when user select its selection and click on submit button then it will get all the selected values using $_post method then using array method it will display one by one all the values on same page. So here is the complete step by step tutorial for How to Get/Display Multiple checkbox selected values in php on same page.

android-project-download-code-button

How to Get/Display Multiple checkbox selected values in php on same page.

Code for checkbox-same-page.php file.

 <!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>How to Get/Display Multiple checkbox selected values on same page using PHP</title>
</head>

<body>

<h2>Pass checkbox checked values on same page.</h2>
 <form method="post" action="">
 <input type="checkbox" name="chk[]" value="Android"><label>Android</label><br/>
 <input type="checkbox" name="chk[]" value="Android Studio"><label>Android Studio</label><br/>
 <input type="checkbox" name="chk[]" value="SDK Manager"><label>SDK Manager</label><br/>
 <input type="checkbox" name="chk[]" value="PHP"><label>PHP</label><br/>
 <input type="checkbox" name="chk[]" value="PHP Basics"><label>PHP Basics</label><br/><br/>
 <input type="submit" name="submit" Value="submit">
 </form>
</br>

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

</body>
</html>

Screenshot:

How to Get/Display Multiple checkbox selected values in php on same page

Click here to download How to Get/Display Multiple checkbox selected values on same page using PHP project file with source code.

Leave a Reply

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