Visualizzazione dei risultati da 1 a 5 su 5
  1. #1
    Utente di HTML.it
    Registrato dal
    Aug 2006
    Messaggi
    165

    passaggio variabili aggiuntive in form inserimento in DB

    Codice PHP:

    <?php require_once('../Connections/prova.php'); ?>
    <?php
    function GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
    {
      
    $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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 tabella_dettagli (immagine1) VALUES (%s)",
                           
    GetSQLValueString($_POST['immagine1'], "text");

      
    mysql_select_db($database_prova$prova);
      
    $Result1 mysql_query($insertSQL$prova) or die(mysql_error());
      
      
    $img1 $_POST['img1']; // QUESTO VALORE LO OTTENGO DAL FORM DELLA PAGINA PRECEDENTE


      
    $insertGoTo ="inseriscifase4.php?var1=<? echo "$img1"; ?>";  // QUI HO BISOGNO DI SCRIVERE
     // IL VALORE DI img1 CHE COME HO DETTO OTTENGO DALLA PAGINA PRECEDENTE MA NEL BROWSER NON ME LO SCRIVE
      
        
    if (isset($_SERVER['QUERY_STRING'])) {
        
    $insertGoTo .= (strpos($insertGoTo'?')) ? "&" "?";
        
    $insertGoTo .= $_SERVER['QUERY_STRING'];
      }
      
    header(sprintf("Location: %s"$insertGoTo));
    }
    ?>  


    <?php
    mysql_select_db
    ($database_prova$prova);
    $query_inserisci "SELECT * FROM tabella_dettagli";
    $inserisci mysql_query($query_inserisci$prova) or die(mysql_error());
    $row_inserisci mysql_fetch_assoc($inserisci);
    $totalRows_inserisci mysql_num_rows($inserisci);
    ?>


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html> 
    <head>
    <title></title>
    </head>
    <body>

         <form method="post" name="form1" action="<?php echo $editFormAction?>">
          <table>
          <tr>
              <td>Immagine1:</td>
            <td><input type="text" name="immagine1" value="<?php echo "$img1"// DEVE SCRIVERE 
    //LO STESSO VALORE CHE OTTIENE DALLA PAGINE PRECEDENTE: QUESTO FUNZIONA! 
    ?>"></td>
          </tr>
            
          <tr valign="baseline">
            <td><input type="submit" value="Inserisci record"></td>
          </tr>
          </table>
              <input type="hidden" name="MM_insert" value="form1">
         </form>
                
    </body>
    </html>
    <?php
    mysql_free_result
    ($inserisci);
    ?>

    Mi aiutate a correggere questo codice?

    quello che non mi funziona è questo

    $insertGoTo ="inseriscifase4.php?var1=<? echo "$img1"; ?>"; nel browser della pagina inserisci4.php mi compare solo inseriscifase4.php?var1= ovvero non passa la variabile img1 che se invece la richiamo con un echo passa correttamente dalla pagina precedente!!

    HELP! HELP! HELP! HELP! HELP!

  2. #2
    Utente di HTML.it L'avatar di moskitoita
    Registrato dal
    Feb 2004
    Messaggi
    1,255

    Re: passaggio variabili aggiuntive in form inserimento in DB

    Codice PHP:

      $insertGoTo 
    ="inseriscifase4.php?var1=".$img1
    "Aiuterò le forze dell'ordine a sventrare eventuali truffatori, eventuali assassini che abbiano utilizzato l'informatica per fini malvagi"

    Salvatore Aranzulla, 15 Aprile 2007, cognome&nome, La7

  3. #3
    Utente di HTML.it
    Registrato dal
    Aug 2006
    Messaggi
    165
    Non funziona

    mi da quest'errore


    Warning: Cannot modify header information - headers already sent by....

  4. #4
    Originariamente inviato da supermix
    Non funziona

    mi da quest'errore

    Warning: Cannot modify header information - headers already sent by....
    Ti suggerisco di leggere questo articolo:

    Warning: Cannot modify header information - headers already sent ...

    In ogni caso, dopo un header location solitamente si inserisce un exit() o funzione equivalente.

  5. #5
    Utente di HTML.it
    Registrato dal
    Aug 2006
    Messaggi
    165
    risolto mancava uno spazio!!

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.