Ciao a tutti, è solo una conferma di quello che sto facendo. Ho un form con un numero indefinito di valori che devo salvare in un database.

Il form è il seguente:
Codice PHP:
<form action="array2.php" method="post">
  <
input type="checkbox" name="risp[]" value="1" /> valore 1

  
<input type="checkbox" name="risp[]" value="2" /> valore 2

  
<input type="checkbox" name="risp[]" value="3" /> valore 3

  
<input type="checkbox" name="risp[]" value="4" /> valore 4

  
<input type="checkbox" name="risp[]" value="5" /> valore 5

  
<input type="checkbox" name="risp[]" value="6" /> valore 6

  
<input type="submit" value="submit" />
</
form
Indipendentemente se i valori contenuti nel campo "value" li recupero dal db oppure staticamente come in questo esempio, li invio ad una pagina che si chiama array2.php che ha il seguente contenuto:

Codice PHP:
// VERIFICO SE ALMENO 1 RISPOSTA E' STATA SELEZIONATA
if (isset($_POST['risp']))
{

// CICLO CON FOREACH PER AVERE UN ELENCO DI TUTTI I VALORI
    
foreach ($_POST['risp'] as $valore)
    {
   
// INSERISCO CON IL CICLO I VALORI UNO PER UNO NEL DB

$query "INSERT INTO tabella (valore) VALUES ('$valore')";
$risultato mysql_query($query) or die("Errore query database: " mysql_error()); 
    }
}    
// DO UN MESSAGGIO SE NEMMENO 1 VALORE E' STATO SELEZIONATO
else
{
    echo 
"Devi scegliere almeno un valore";

Quello che vorrei sapere è se il procedimento è giusto per salvare i valori risultanti oppure se esistono procedimenti definiti "+ corretti".

Grazie!