Ragazzi, ho creato un upload di immagini per inserire delle immagini in altre pagine, mi funziona pure, il problema è uno non riesco perchè ad inviare al DB tutti gli altri dati, che mi servono poi inserire ogni immagine in una pagina diversa. Il succo è perchè questi dati non vengono inviati al DB?


Codice PHP:
<?php
session_start 
();

include 
'db.inc.php';

$db mysql_connect (MYSQL_HOSTMYSQL_USERMYSQL_PASSWORD) or 
die(
'Non Ã¨ possibile collegarsi al db!');
mysql_select_db(MYSQL_DB$db) or die (mysql_error($db));

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Admin -<?php echo $_SESSION['user']; ?></title>
<script>
function funzione_faiqualcosa(valore){
if(valore==0){
document.location.href='invia_img?tipo='+0;
}else{
document.location.href='invia_img.php?tipo='+valore;
}
}
</script> 
</head>

<body>
<div align="center">

<?php
if (isset ($_SESSION['logged']) && $_SESSION['logged'] == 1) {
    
//l'utente ha eseguito l'accesso
?>
<div class="header">

</div>
<div class="menu">
<div class="menu_header">
 <ul>
    <li class="linea2">[url="index.php"]Foto Testata[/url]
    <li class="linea2">[url="#"]Contenuti[/url]
    <li class="linea2">[url="#"]Photogallery[/url]
    <li class="linea">[url="exit.php"][b]Esci[b][/url]
    <li class="linea">[url="mod_adm.php"][b]<font color="#000">Admin:</font> <?php echo $_SESSION['user']; ?>[/b][/url][/list]
</div>
</div>
<?php
include 'db.inc.php';

$db mysql_connect (MYSQL_HOSTMYSQL_USERMYSQL_PASSWORD) or 
die(
'Non Ã¨ possibile collegarsi al db!');
mysql_select_db(MYSQL_DB$db) or die (mysql_error($db));

$tipo $_GET['tipo'];
?>

<form method="post" action="invia_img.php" name="formData" enctype="multipart/form-data">
<input type="hidden" name="op" value="mod">
<input type="hidden" name="tipo" value="<? echo $tipo ?>">
<fieldset>
<legend>Inserisci foto</legend>


<label for="firstname" accesskey="f">Pagina:</label> 
<select name="tipo" onchange="funzione_faiqualcosa(this.value)">
<? if ($tipo == 1){ ?>
<option value="1" selected="selected" >Homepage</option>
<? }else{ ?>
<option value="1">Homepage</option>
<? ?>
<? 
if ($tipo == 2){ ?>
<option value="2" selected="selected">La pescheria</option>
<? }else{ ?>
<option value="2">La pescheria</option>
<? ?>
<? 
if ($tipo == 3){ ?>
<option value="3" selected="selected">Take away</option>
<? }else{ ?>
<option value="3">Take away</option>
<? ?>
<? 
if ($tipo == 4){ ?>
<option value="4" selected="selected">Fish bar</option>
<? }else{ ?>
<option value="4">Fish bar</option>
<? ?>
<? 
if ($tipo == 5){ ?>
<option value="5" selected="selected">Menù</option>
<? }else{ ?>
<option value="5">Menù</option>
<? ?>
<? 
if ($tipo == 6){ ?>
<option value="6" selected="selected">Foto contenuto pescheria</option>
<? }else{ ?>
<option value="6">Foto contenuto pescheria</option>
<? ?>
<? 
if ($tipo == 7){ ?>
<option value="7" selected="selected">Foto contenuto take away</option>
<? }else{ ?>
<option value="7">Foto contenuto take away</option>
<? ?>
<? 
if ($tipo == 8){ ?>
<option value="8" selected="selected">Foto contenuto fish bar</option>
<? }else{ ?>
<option value="8">Foto contenuto take fish bar</option>
<? ?>
</select>


<input name="MAX_FILE_SIZE" type="hidden" value="9995242880" />
<? if ($tipo == 1){ ?>
<label for="firstname" accesskey="f">Foto testata(525x186)</label>
<input type="file" name="foto1"> 

<label for="firstname" accesskey="f"><input type="submit" value="inserisci" /></label>
<? ?>
<? 
if ($tipo == 2){ ?>
<label for="firstname" accesskey="f">Foto testata(525x186)</label>
<input type="file" name="foto2"> 

<label for="firstname" accesskey="f"><input type="submit" value="inserisci" /></label>
<? ?>
<? 
if ($tipo == 3){ ?>
<label for="firstname" accesskey="f">Foto testata(525x186)</label>
<input type="file" name="foto3"> 

<label for="firstname" accesskey="f"><input type="submit" value="inserisci" /></label>
<? ?>
<? 
if ($tipo == 4){ ?>
<label for="firstname" accesskey="f">Foto testata(525x186)</label>
<input type="file" name="foto4"> 

<label for="firstname" accesskey="f"><input type="submit" value="inserisci" /></label>
<? ?>
<? 
if ($tipo == 5){ ?>
<label for="firstname" accesskey="f">Foto testata(525x186)</label>
<input type="file" name="foto5"> 

<label for="firstname" accesskey="f"><input type="submit" value="inserisci" /></label>
<? ?>
<? 
if ($tipo == 6){ ?>
<label for="firstname" accesskey="f">Foto contenuto(150x75)</label>
<input type="file" name="foto6"> 

<label for="firstname" accesskey="f"><input type="submit" value="inserisci" /></label>
<? ?>
<? 
if ($tipo == 7){ ?>
<label for="firstname" accesskey="f">Foto contenuto(150x75)</label>
<input type="file" name="foto7"> 

<label for="firstname" accesskey="f"><input type="submit" value="inserisci" /></label>
<? ?>
<? 
if ($tipo == 8){ ?>
<label for="firstname" accesskey="f">Foto contenuto(150x75)</label>
<input type="file" name="foto8"> 

<label for="firstname" accesskey="f"><input type="submit" value="inserisci" /></label>
<? ?>
</fieldset>
</form>

<?php
include 'db.inc.php';

$db mysql_connect (MYSQL_HOSTMYSQL_USERMYSQL_PASSWORD) or 
die(
'Non Ã¨ possibile collegarsi al db!');
mysql_select_db(MYSQL_DB$db) or die (mysql_error($db));

//cattura i dati dal modulo
$foto1 $_POST['foto1'];
$foto2 $_POST['foto2'];
$foto3 $_POST['foto3'];
$foto3a $_POST['foto3a'];
$foto4 $_POST['foto4'];
$foto4a $_POST['foto4a'];
$foto5 $_POST['foto5'];
$foto6 $_POST['foto6'];
$foto7 $_POST['foto7'];
$foto8 $_POST['foto8'];
$tipo $_POST['tipo'];

$a=rand(19);
$b=rand(19);
$c=rand(19);
$d=rand(19);
$e=rand(19);
$f=rand(19);
$ante=$a.$b.$c.$d.$e.$f;
if(
$tipo == 1){
//immagine principale
$uploaddir "./uploads/";
$uploadfile $ante .$_FILES['foto1']['name'];
$uploadfile1 $uploaddir .$ante .$_FILES['foto1']['name'];
$time=time();
if (
move_uploaded_file($_FILES['foto1']['tmp_name'], $uploadfile1)) {
    print 
"$uploadfile1 Allegato was successfully uploaded. ";
} else {
    print 
"$uploadfile1 Possible file upload attack!  Here's some debugging info:\n";
}
}

if(
$tipo == 2){
//foto2
$uploaddir "./uploads/";
$uploadfile2 $ante .$_FILES['foto2']['name'];
$uploadfile2 $uploaddir .$ante .$_FILES['foto2']['name'];
$time=time();
if (
move_uploaded_file($_FILES['foto2']['tmp_name'], $uploadfile2)) {
    print 
"$uploadfile1 Allegato was successfully uploaded. ";
} else {
    print 
"$uploadfile1 Possible file upload attack!  Here's some debugging info:\n";
}
}
if (
$tipo == 3){
//foto3
$uploaddir "./uploads/";
$uploadfile3 $ante .$_FILES['foto3']['name'];
$uploadfile3 $uploaddir .$ante .$_FILES['foto3']['name'];
$time=time();
if (
move_uploaded_file($_FILES['foto3']['tmp_name'], $uploadfile3)) {
    print 
"$uploadfile1 Allegato was successfully uploaded. ";
} else {
    print 
"$uploadfile1 Possible file upload attack!  Here's some debugging info:\n";
}
}
if (
$tipo == 4){
//foto4
$uploaddir "./uploads/";
$uploadfile4 $ante .$_FILES['foto4']['name'];
$uploadfile4 $uploaddir .$ante .$_FILES['foto4']['name'];
$time=time();
if (
move_uploaded_file($_FILES['foto4']['tmp_name'], $uploadfile4)) {
    print 
"$uploadfile1 Allegato was successfully uploaded. ";
} else {
    print 
"$uploadfile1 Possible file upload attack!  Here's some debugging info:\n";
}
}
if (
$tipo == 5){
//foto5
$uploaddir "./uploads/";
$uploadfile5 $ante .$_FILES['foto5']['name'];
$uploadfile5 $uploaddir .$ante .$_FILES['foto5']['name'];
$time=time();
if (
move_uploaded_file($_FILES['foto5']['tmp_name'], $uploadfile5)) {
    print 
"$uploadfile1 Allegato was successfully uploaded. ";
} else {
    print 
"$uploadfile1 Possible file upload attack!  Here's some debugging info:\n";
}
}
if (
$tipo == 6){
//foto5
$uploaddir "./uploads/";
$uploadfile6 $ante .$_FILES['foto6']['name'];
$uploadfile6 $uploaddir .$ante .$_FILES['foto6']['name'];
$time=time();
if (
move_uploaded_file($_FILES['foto6']['tmp_name'], $uploadfile6)) {
    print 
"$uploadfile1 Allegato was successfully uploaded. ";
} else {
    print 
"$uploadfile1 Possible file upload attack!  Here's some debugging info:\n";
}
}
if (
$tipo == 7){
//foto5
$uploaddir "./uploads/";
$uploadfile7 $ante .$_FILES['foto5']['name'];
$uploadfile7 $uploaddir .$ante .$_FILES['foto7']['name'];
$time=time();
if (
move_uploaded_file($_FILES['foto7']['tmp_name'], $uploadfile7)) {
    print 
"$uploadfile1 Allegato was successfully uploaded. ";
} else {
    print 
"$uploadfile1 Possible file upload attack!  Here's some debugging info:\n";
}
}
if (
$tipo == 8){
//foto5
$uploaddir "./uploads/";
$uploadfile8 $ante .$_FILES['foto8']['name'];
$uploadfile8 $uploaddir .$ante .$_FILES['foto5']['name'];
$time=time();
if (
move_uploaded_file($_FILES['foto8']['tmp_name'], $uploadfile8)) {
    print 
"$uploadfile1 Allegato was successfully uploaded. ";
} else {
    print 
"$uploadfile1 Possible file upload attack!  Here's some debugging info:\n";
}


if(
$tipo == 1){
$result mysql_query ("insert into foto(foto,tipo) values('$uploadfile1','$tipo')");
}
if(
$tipo == 2){
$result mysql_query ("insert into foto(foto,tipo) values('$uploadfile2','$tipo')");
}
if(
$tipo == 3){
$result mysql_query ("INSERT INTO foto
                      (foto,tipo)
                       VALUES 
                      ('
$uploadfile3','$tipo')");
}
if(
$tipo == 4){
$result mysql_query ("insert into foto(foto,tipo) values('$uploadfile4','$tipo')");
}
if(
$tipo == 5){
$result mysql_query ("insert into foto(foto,tipo) values('$uploadfile5','$tipo')");
}
if(
$tipo == 6){
$result mysql_query ("insert into foto(foto,tipo) values('$uploadfile6','$tipo')");
}
if(
$tipo == 7){
$result mysql_query ("insert into foto(foto,tipo) values('$uploadfile7','$tipo')");
}
if(
$tipo == 8){
$result mysql_query ("insert into foto(foto,tipo) values('$uploadfile8','$tipo')");
}

if(
$result)    { echo"<script language=javascript>";
            echo
"document.location.href='home.php?ids=$tipo'";
            echo
"</script>";}
else echo
"Inserimento fallito".mysql_error();

}


?>
<?php
} else {
    
//l'utente non ha eseguito l'accesso
?>
<div class="errore">


Per accedere a questa sezione del sito devi effettuare il [url="login.php"]Login[/url].</div>
<?php
}
?>
</body>
</html>