ciao a tutto,
sto costruendo 1 form per l'invio dei dati in una tabella di mysql (cosa che normalmente faccio con DW) ma ora mi occorre anche l'inserimento di 2 foto e li qualche problema c'e'!
posto il codice php e html
pleease help me!
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "aggiunta")) {
$insertSQL = sprintf("INSERT INTO oggetti (cod_oggetto, nome_oggetto, descrizione_parziale, descrizione_completa, prezzo, quantita, foto_anteprima, foto_ingrandita, categoria) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['codice_prodotto'], "text"),
GetSQLValueString($_POST['nome_prodotto'], "text"),
GetSQLValueString($_POST['descrizione_parziale'], "text"),
GetSQLValueString($_POST['descrizione_completa'], "text"),
GetSQLValueString($_POST['prezzo'], "text"),
GetSQLValueString($_POST['quantita'], "text"),
GetSQLValueString($_POST['file1'], "text"),
GetSQLValueString($_POST['file2'], "text"),
GetSQLValueString($_POST['categoria'], "text"));
mysql_select_db($database_conn_aquolina, $conn_aquolina);
$Result1 = mysql_query($insertSQL, $conn_aquolina) or die(mysql_error());
}
?>
--------------------------------------------------------------------------------------
<form action="<?php echo $editFormAction; ?>" method="POST" enctype="multipart/form-data" name="aggiunta" id="aggiunta">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="16%" align="right">Codice prodotto</td>
<td width="1%"></td>
<td width="83%"><input type="text" name="codice_prodotto" id="codice_prodotto" /></td>
</tr>
<tr>
<td colspan="3" height="5"></td>
</tr>
<tr>
<td align="right">Nome prodotto</td>
<td></td>
<td><input type="text" name="nome_prodotto" id="nome_prodotto" /></td>
</tr>
<tr>
<td colspan="3" height="5"></td>
</tr>
<tr>
<td align="right">Descrizione parziale</td>
<td></td>
<td><input type="text" name="descrizione_parziale" id="descrizione_parziale" /></td>
</tr>
<tr>
<td colspan="3" height="5"></td>
</tr>
<tr>
<td align="right">Descrizione completa</td>
<td></td>
<td><input type="text" name="descrizione_completa" id="descrizione_completa" /></td>
</tr>
<tr>
<td colspan="3" height="5"></td>
</tr>
<tr>
<td align="right">Prezzo</td>
<td></td>
<td><input type="text" name="prezzo" id="prezzo" /></td>
</tr>
<tr>
<td colspan="3" height="5"></td>
</tr>
<tr>
<td align="right">Categoria</td>
<td></td>
<td><input type="text" name="categoria" id="categoria" /></td>
</tr>
<tr>
<td colspan="3" height="5"></td>
</tr>
<tr>
<td align="right">Quantita'</td>
<td></td>
<td><input type="text" name="quantita" id="quantita" /></td>
</tr>
<tr>
<td colspan="3" height="5"></td>
</tr>
<tr>
<td align="right">Foto in anteprima</td>
<td></td>
<td><input type="file" name="file1" id="foto_anteprima" /></td>
</tr>
<tr>
<td colspan="3" height="5"></td>
</tr>
<tr>
<td align="right">Foto ingrandita</td>
<td></td>
<td><input type="file" name="file2" id="foto_ingrandita" /></td>
</tr>
<tr>
<td colspan="3" height="10"></td>
</tr>
<tr>
<td></td>
<td></td>
<td><input type="submit" name="aggiungi" id="aggiungi" value="Upload" /></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="aggiunta" />
</form>