First off you need to set your checkboxes names
and turn them to name=Marca[]
<form method="post" action="form.php?process">
<p>MARCA: <br><br>
<input type="checkbox" name="Marca[]" value="ACER">ACER
<input type="checkbox" name="Marca[]" value="AOC">AOC
<input type="checkbox" name="Marca[]" value="APPLE">APPLE
<input type="submit" name="Submit" value="Submit" />
</form>
Then on your form.php
process the values:
Note: You have to understand, you can't just put $_POST['Marca']
and concatenate them into the string, you have to get each value and build the insert query.
if(isset($_GET['process'])) {
$marca = isset($_POST['Marca']) ? $_POST['Marca'] : null;
if(count($marca) < 3) {
// your validation that no checkboxes were selected
$msg = 'You need to select at least 3 values';
header("Location: form.php?m=".$msg);
}
$values = implode(',', $marca);
$statement = "INSERT INTO `lista_precios` (`Marca`) VALUES ('$values');";
// should result into
// INSERT INTO `lista_precios` (`Marca`) VALUES ('ACER,AOC,APPLE');
// then continue on your query code
$query = mysql_query($statement);
$msg = ($query && mysql_affected_rows() > 0) ? 'Inserted' : 'Not Inserted';
header("Location: form.php?m=".$msg);
}