This code is useful for multiple checkboxes. I'm using array facility with in this code.
<html>
<form action = "sample_checkbox_1.php" method = "post">
Code: <input type = "text" name = "code" size = "10"><br>
<input type = "checkbox" name = colors[] value = "red">Red
<input type = "checkbox" name = colors[] value = "blue">Blue
<input type = "checkbox" name = colors[] value = "green">Green
<input type = "checkbox" name = colors[] value = "megenta">Megenta
<input type = "submit" name "Submit" value = "Submit">
</form>
</html>
<?php
// In MySQL, pls make one table i.e.
// colors: (colorcode varchar(20), colorname varchar(20));
//declare information for database connectivity
mysql_connect(localhost,username,pwd);
mysql_connect_db(databasename);
$ecode = $_POST['code'];
$ec = $_POST['colors'];
//this function store ur values on the table.
function print_selected_values($e_code,$area_array) {
foreach($area_array as $color_value){
$query = "insert into colors(colors,code)values('$color_value','$e_code')";
$result = mysql_query($query) or die ("query not made");
}
print("entry successfully made....!");
}
print_selected_values($ecode,$ec);
?>