Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it
    Registrato dal
    Apr 2006
    Messaggi
    181

    [php] problema per traferire dati tra due pagine

    Ciao a tutti ho un grosso problema e mi serve un grosso aiuto urgente per favore aiutatemi.
    Ho realizzato una pagina php per inserire dei dati in un db mysql. dato che la query di insert è molto grande perchè ci sono molti campi ho realizzato la pagina con dreamweaver e eseguito la query tramite la procedura semplificata (non so se ce l'avete presente).
    ora ho un problema devo passare un dato che l'utente ha inserito in un campo del forum ad un'altra pagina ma non so come fare.
    praticamente non posso passare questo valore tramite post perchè il form è stato impostato dal programma per fare il redirect sulla pagina in quanto la query è scritta nella stessa pagina dove è presente il modulo che l'utente deve compilare. come posso far passare quel valore? vi mando il codice della pagina solo la parte più importante perchè è lunghissimo

    codice:
    <?php require_once('Connections/sementiero.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 = $HTTP_SERVER_VARS['PHP_SELF'];
    if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
      $editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];
    }
    
    if ((isset($HTTP_POST_VARS["MM_insert"])) && ($HTTP_POST_VARS["MM_insert"] == "form1")) {
      $insertSQL = sprintf("INSERT INTO questionario (nome, localita, sede, costitutore, moltiplicatore, tipologia, res, viv, mi, me, cf, fa1, fb1, fc1, fa2, fb2, fc2, fa3, fb3, fc3, fa4, fb4, fc4, fa5, fb5, fc5, fa6, fb6, fc6, fa7, fb7, fc7, fa8, fb8, fc8, fa9, fb9, fc9, dm1, dp1, dm2, dp2, dm3, dp3, dm4, dp4, dp5, pf, us, uf, cm, hm, ap1, a1, ap2, a2, ap3, a3, ap4, a4, a5, r1, ra1, r2, ra2, r3, ra3, r4, ra4, r5, ra5, r6, ra6, r7, ra7, r8, ra8, r9, ra9) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                           GetSQLValueString($HTTP_POST_VARS['nome'], "text"),
                           GetSQLValueString($HTTP_POST_VARS['localita'], "text"),
                           GetSQLValueString($HTTP_POST_VARS['sede'], "text"),
                           GetSQLValueString(isset($HTTP_POST_VARS['costitutore']) ? "true" : "", "defined","1","0"),
    
                          continua taglio per semplificare .....
    
      mysql_select_db($database_sementiero, $sementiero);
      $Result1 = mysql_query($insertSQL, $sementiero) or die(mysql_error());
      $insertGoTo = "q2.php";
      if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
        $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
        $insertGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
      }
      header(sprintf("Location: %s", $insertGoTo));
    }
    ?>
    <html>
    <body>
    <form action="" method="POST" name="form1" target="_self">
    continua...

  2. #2
    esistono le sessioni.. setta una variabile di sessione con il valore che ti interessa..

    Questa volta, più che un voto.. è favoreggiamento.

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.