Ho fatto diverse prove e questo codice è lunico che funziona... ma non come vorrei io
<form action="script.php" method="post">
<input type="checkbox" name="selez"> verde<br>
<input type="checkbox" name="selez"> bianco<br>
<input type="checkbox" name="selez"> rosso<br>
<input type="submit" value="Inserisci"><br><br/>
</form>
<?php
$host = 'localhost';
$user = '@user';
$password = '@pass';
$database = '@db';
$db = mysql_connect($host, $user, $password)
or die ("Impossibile connettersi al server $host");
mysql_select_db($database, $db)
or die ("Impossibile connettersi al database $database");
$checkbox=$_POST['selez'];
$query=("INSERT INTO famiglia (verde, bianco, rosso)
VALUES ('1', '1', '1')");
$sql=mysql_query($query) or die ("Query error:" . mysql_error());
?>
La tabella MySQL:
Campo - Tipo - Null - Predefinito - Extra
Id - int(11) - No - ... - auto increment
verde - tinyint(1) - Si - NULL
bianco - tinyint(1) - Si - NULL
rosso - tinyint(1) - Si - NULL
Dove sbaglio?