Don't Miss

How to get data from HTML Checkbox in PHP

By on January 23, 2018

index.html

<form action=”insert.php” method=”post”>
<input name=”courses[]” type=”checkbox” value=”oop” />OOP
<input name=”courses[]” type=”checkbox” value=”ds” />DS
<input name=”courses[]” type=”checkbox” value=”db” />DB
<input name=”courses[]” type=”checkbox” value=”coal” />COAL
</form>

 

insert.php

<?php
$members=””;
$course = $_POST[‘courses’];
foreach($course as $selected)
{
$members .= $selected.’,’;
}

$vale = explode(“,”,$members);
print_r(array_filter($vale));

?>

About CodingBazz

Leave a Reply

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