Last Updated: February 25, 2016
·
1.187K
· 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

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

PHP applications still send a browser full of JavaScript. Hardening the server does not inventory the payment, analytics, and plugin scripts that run after the HTML is delivered.

Security insights from Cside