Salve, ho un problema con uno script php: la funzione update non modifica il database ma
i vari record rimangono sempre gli stessi. Qualcuno può aiutarmi?
Questo è il codice:
<form method="post" action="modifica-prodotto.php">
<table width="90%" border="0" cellpadding="8">
<tr style="vertical-align: top">
<td width="10%" style="text-align: right">
<label class="etichetta">Codice</label> </td>
<td colspan="2">
<input type="text" name="codice"></td> </tr>
<tr style="vertical-align: top">
<td style="text-align: right">
<label class="etichetta">Nome</label> </td>
<td colspan="2"> <input type="text" name="nome" size="30"> </td>
</tr>
<tr style="vertical-align: top"> </tr>
<tr style="vertical-align: top">
<td style="text-align: right"> <label class="etichetta">Descrizione</label> </td>
<td width="87%">
<textarea name="descrizione" cols="46" rows="4"></textarea></td>
</tr>
<tr style="vertical-align: top">
<td style="text-align: right">
<label class="etichetta">Immagine</label></td>
<td colspan="2"><input name="immagine" type="file" size="30"></td>
</tr>
<tr style="vertical-align: top">
<td style="text-align: right"> <label class="etichetta">Prezzo</label></td>
<td colspan="2"> <input name="prezzo" type="text"> </td>
</tr>
</table>
<table width="566" cellspacing="0" cellpadding="0">
<tr>
<td height="50" align="left"></td>
<td width="90" height="50" align="center"></td>
<td width="73" height="50"></td>
<td width="73" height="50" align="center"></td>
<td width="73" height="50"></td>
<td width="87" height="50" align="center"><button type="submit" name="modifica">[img]../immagini/invia.png[/img]</button></td>
<td width="18" height="50"></td>
<td width="95" height="50" align="center"><button type="reset" name="annulla">[img]../immagini/cancel.png[/img]</button></td>
<td width="63" height="50"></td>
</tr>
<tr>
<td width="5" height="30"></td>
<td height="30" align="left"></td>
<td width="73" height="30" align="center"></td>
<td width="73" height="30"></td>
<td width="73" height="30" align="center"></td>
<td width="87" height="30"><div align="center">Modifica
</div></td>
<td width="18" height="30" align="center"></td>
<td width="95" height="30"><div align="center">Annulla</div></td>
</tr>
</table>
</form>
<?php
include "../config_db.php";
if (isset($_POST['modifica'])){
$id_prodotto = $_POST['id_prodotto'];
$codice = $_POST['codice'];
$nome = $_POST['nome'];
$descrizione = $_POST['descrizione'];
$immagine = $_POST['immagine'];
$prezzo = $_POST['prezzo'];
$sql = "UPDATE prodotti SET codice = '$codice', nome = '$nome', descrizione = '$descrizione', immagine = '$immagine', prezzo = '$prezzo' WHERE id_prodotto = '$id_prodotto'";
$res = mysql_query($sql) OR DIE ("
Errore Numero: ".mysql_errno() ."
Descrizione: ". mysql_error()."<hr />");
echo "<script type=\"text/javaScript\">";
echo "alert(\"Prodotto modificato!\")";
echo "</script>";
}
?>