Spero vada meglio.....

Codice PHP:
<?
require 'auth_user.php';
if (!isset(
$_POST['lista_foto'])) $_POST['lista_foto']="";
if (isset(
$_POST['go'])){

$error false;
$post = array();
if (isset(
$_POST['go'])){
$post[0] = trim($_POST['categoria']);
$post[1] = trim($_POST['sottocategoria']);
$post[2] = trim($_POST['sottocategoriadescr']);
$post[3] = trim($_POST['titolo']);
$post[4] = trim($_POST['annuncio']);
$post[5] = trim($_POST['lista_foto']);
$post[6] = trim($_POST['regione']);
$post[7] = trim($_POST['comune']);
$post[8] = trim($_POST['sottocategoriatype']);
$post[9] = trim($_POST['contatto']);
$post[10] = trim($_POST['link']);

//check case incomplete category (subcat)
if ($_POST['cat_type']== '1'){
foreach (
$_POST as $key => $value) {
if((
strlen(trim($post[3]))==0) && ($key != 'lista_foto') && ($key != 'sottocategoriatype') && ($key != 'sottocategoriadescr')){
$errore "<div align=center><font color=\"red\">Tutti i campi con l'asterisco sono obbligatori</font></div>";
$error true;
}
}
}elseif (
$_POST['cat_type']== '2'){//check case complete category (subtype)
foreach ($_POST as $key => $value) {
if((
strlen(trim($value))==0) && ($key != 'lista_foto') && ($key != 'sottocategoriadescr')){
$errore "<div align=center><font color=\"red\">Tutti i campi con l'asterisco sono obbligatori</font></div>";
$error true;
}
}
}elseif (
$_POST['cat_type']== 'true'){//check case complete category
foreach ($_POST as $key => $value) {
if((
strlen(trim($value))==0) && ($key != 'lista_foto')){
$errore "<div align=center><font color=\"red\">Tutti i campi con l'asterisco sono obbligatori</font></div>";
$error true;
}
}
}

}

if (
$_POST['go'] != "Inserisci foto" && $_POST['go'] != "inserisci"){
$lista split(':',$_POST['lista_foto']);
$_POST['lista_foto'] = "";
for (
$i=0$i<sizeof($lista)-1$i++)
{
if (
$lista[$i] != $_POST['image'])
{
$_POST['lista_foto'].=$lista[$i].":";
} else
{
unlink ("tmp/miniature/".$lista[$i]);
unlink ("tmp/".$lista[$i]);
}
}
$_POST['go'] = "Inserisci foto";
}

if (
$_POST['go'] == "Inserisci foto"){
$filename=$_FILES['nomefile']['tmp_name'];
$error true;
list(
$h,$w,$type) = getimagesize($filename);
if ( 
$type != and $type != and $type != 3) { //--> $type = 2 indica un file JPEG
$incorrect"<div align=center>Tipo immagine d'immagine non supportata $type</div>";
} else {
$nomefile time().$_FILES['nomefile']['name'];
$nomefile replace_spaces($nomefile);
if (
$w>640 || $h>480resizeImg($filename,800,600,"tmp/".$nomefile);
else 
copy($filename,"tmp/".$nomefile);
resizeImg($filename,70,50,"tmp/miniature/".$nomefile);
$_POST['lista_foto'].=$nomefile.":";
}
$errore="";
}
if (!
$error){
//aggiungi annuncio

$sql "INSERT INTO
annunci
(categoria,
subcategoria,
subcategoriadescr,
titolo,
contenuto,
contatto,
utente,
img,
data,
regione,
comune,
link,
subcategoriatype)
VALUES
('"
.$post[0]."',
'"
.$post[1]."',
'"
.$post[2]."',
'"
.fix_special_char_sql($post[3])."',
'"
.fix_special_char_sql($post[4])."',
'"
.fix_special_char_sql($post[9])."',
"
.$_SESSION['userid'].",
'"
.$post[5]."',
'"
.timestamp(time())."',
'"
.$post[6]."',
'"
.$post[7]."',
'"
.fix_special_char_sql($post[10])."',
'"
.$post[8]."')";

$result mysql_query($sqlCONN);

print 
"

<table align=\"center\" bgcolor=\"#EEEEEE\" height=\"100\" width=\"300\" style=\"border: 1px solid #CCCCFF;\">
<tr>
<td>
<div align=center>Record aggiunto con successo <img src=\"img/yes.gif\">

Sarai rediretto verso la Homepage

</td>
</tr>
</table>"
;
$lista split(':',$_POST['lista_foto']);
for (
$i=0$i<sizeof($lista)-1$i++)
{
rename("tmp/".$lista[$i],"img_annunci/".$lista[$i]);
rename("tmp/miniature/".$lista[$i],"img_annunci/miniature/".$lista[$i]);
}
header("Refresh: 2; URL=index.php");
$redirect true;
}
}