devi fare una roba tipo:
Codice PHP:
<?php
if (!function_exists("GetSQLValueString")) {
function 
GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue "")
{
if (
PHP_VERSION 6) {
$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"] == "form1")) {
$insertSQL sprintf("INSERT INTO prodotti (id_menu, codice, titolo, prezzo, foto, foto_thumbs, scheda) VALUES (%s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['id_menu'], "text"),
GetSQLValueString($_POST['codice'], "text"),
GetSQLValueString($_POST['titolo'], "text"),
GetSQLValueString($_POST['prezzo'], "double"),
GetSQLValueString($_FILES['foto']['name'], "text"),
GetSQLValueString($_FILES['foto']['name'], "text"),
GetSQLValueString($_POST['scheda'], "text"));

mysql_select_db($database_conn$conn);
$Result1 mysql_query($insertSQL$conn) or die(mysql_error());

// QUA INSERISCO L'UPLOAD DEL FILE!!!

$idir "image_files/"// Path To Images Directory
$tdir "image_files/thumbs/"// Path To Thumbnails Directory
$twidth "120"// Maximum Width For Thumbnail Images
$theight "125"// Maximum Height For Thumbnail Images

$url $_FILES['foto']['name']; // Set $url To Equal The Filename For Later Use
if ($_FILES['foto']['type'] == "image/jpg" || $_FILES['foto']['type'] == "image/jpeg" || $_FILES['foto']['type'] == "image/pjpeg") {
$file_ext strrchr($_FILES['foto']['name'], '.'); // Get The File Extention In The Format Of , For Instance, .jpg, .gif or .php
$copy copy($_FILES['foto']['tmp_name'], "$idir$_FILES['foto']['name']); // Move Image From Temporary Location To Permanent Location
if ($copy) { // If The Script Was Able To Copy The Image To It's Permanent Location
print 'Immagine caricata CORETTAMENTE.
'
// Was Able To Successfully Upload Image
$simg imagecreatefromjpeg("$idir$url); // Make A New Temporary Image To Create The Thumbanil From
$currwidth imagesx($simg); // Current Image Width
$currheight imagesy($simg); // Current Image Height
if ($currheight $currwidth) { // If Height Is Greater Than Width
$zoom $twidth $currheight// Length Ratio For Width
$newheight $theight// Height Is Equal To Max Height
$newwidth $currwidth $zoom// Creates The New Width
} else { // Otherwise, Assume Width Is Greater Than Height (Will Produce Same Result If Width Is Equal To Height)
$zoom $twidth $currwidth// Length Ratio For Height
$newwidth $twidth// Width Is Equal To Max Width
$newheight $currheight $zoom// Creates The New Height
}
$dimg imagecreate($newwidth$newheight); // Make New Image For Thumbnail
imagetruecolortopalette($simgfalse256); // Create New Color Pallete
$palsize ImageColorsTotal($simg);
for (
$i 0$i $palsize$i++) { // Counting Colors In The Image
$colors ImageColorsForIndex($simg$i); // Number Of Colors Used
ImageColorAllocate($dimg$colors['red'], $colors['green'], $colors['blue']); // Tell The Server What Colors This Image Will Use
}
imagecopyresized($dimg$simg0000$newwidth$newheight$currwidth$currheight); // Copy Resized Image To The New Image (So We Can Save It)
imagejpeg($dimg"$tdir$url); // Saving The Image
imagedestroy($simg); // Destroying The Temporary Image
imagedestroy($dimg); // Destroying The Other Temporary Image
print 'miniatura creata correttamente'// Resize successful
} else {
print 
'<font color="#FF0000">ERROR: Unable to upload image.</font>'// Error Message If Upload Failed
}
} else {
print 
'<font color="#FF0000">ERROR: Wrong filetype (has to be a .jpg or .jpeg. Yours is '// Error Message If Filetype Is Wrong
print $file_ext// Show The Invalid File's Extention
print '.</font>';
}
}



}

// ho tolto per semplificare i due recordset sotto..
?>
vedi se va, io ho copiato e incollato le tue paginette togliendo solo le cose ovviamente errate..
Dovrai poi mettere dei controlli se il file è vuoto, oppure se i campi testo sono vuoti e robe simili