Last Updated: February 25, 2016
·
952
· dubrod

Input multiple checkboxes to MySQL

PHP

//class
//function
class Plan_Process {
function do_plan($visible, $plan_submit) {
if(isset($plan_submit)) {
//print_r($visible);
//exit();
$visible = implode(',', $visible);
$query = &SadoFactory::getInstance();                
$query->insert('plans',
    array('visible_to' => $visible)
);
    echo " PLAN CREATED.";
} // eof if $submit
} } 

FUNCTION: top of page

//process 
$Plan_Process = new Plan_Process;
$Plan_Process->do_plan($_POST['visible'], $_POST['plan_submit']);

HTML

//form area
<form method="post" enctype="multipart/form-data">
<input type="checkbox" name="visible[vip]" value="VIPs"> VIPs &nbsp;
<input type="checkbox" name="visible[friends]" value="Friends"> Friends   
<input type="checkbox" name="visible[family]" value="Family"> Family       
<input type="checkbox" name="visible[biz]" value="Business"> Business 
<input type="checkbox" name="visible[exs]" value="Exs"> Exs