in pratica prima c'è questo codice che inserisce i record
Codice PHP:
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO partecipanti (evento, username, presente) VALUES (%s, %s, %s)",
GetSQLValueString($_POST['evento'], "text"),
GetSQLValueString($_POST['username'], "text"),
GetSQLValueString($_POST['presente'], "int"));
mysql_select_db($database_server, $server);
$Result1 = mysql_query($insertSQL, $server) or die(mysql_error());
$insertGoTo = "modificapresenti.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
e invece questo è il codice del form intero
Codice PHP:
<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
<table align="center">
<tr valign="baseline">
<td align="left" valign="top" nowrap="nowrap">Nome socio:</td>
<td> <select name="username[]" size="12" multiple="multiple">
<?php
do {
?>
<option value="<?php echo $row_elencosenzarisposta['hash']?>"><?php echo $row_elencosenzarisposta['fname']." ".$row_elencosenzarisposta['lname']?></option>
<?php
} while ($row_elencosenzarisposta = mysql_fetch_assoc($elencosenzarisposta));
$rows = mysql_num_rows($elencosenzarisposta);
if($rows > 0) {
mysql_data_seek($elencosenzarisposta, 0);
$row_elencosenzarisposta = mysql_fetch_assoc($elencosenzarisposta);
}
?>
</select></td>
</tr>
<tr> </tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"></td>
<td valign="baseline"><table>
<tr>
<td><input type="radio" name="presente" value="1" />
Presente</td>
</tr>
<tr>
<td><input type="radio" name="presente" value="0" />
Assente</td>
</tr>
</table></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"></td>
<td><input type="submit" value="Conferma" /></td>
</tr>
</table>
<input type="hidden" name="evento" value="<?php echo $_GET['id']; ?>" />
<input type="hidden" name="MM_insert" value="form1" />
</form>