Passing $ _POST by URL

0
  • I have a form that is dynamically mounted according to the preferences of each user and is submitted via post to the page that makes the process.

  • On the process page I need, among other things, to load an iframe that will bring in extra information, according to the information in the dynamic form of the first screen.

    My problem is right there: how do I pass the information to the iframe to bring in the extra information?

    Example: Form

    <form method="post" action="processa.php">
    
       <label>Ano</label>
       <div>
          <select id="ano" name="ano">
             <option value="0">2000</option>
             <option value="1">2001</option>
             <option value="2">2002</option>
          </select>                     
       </div>
    
       <label>Mes</label>
       <div>
          <input type="text" id="mes" name="mes">                     
       </div>
    
       <label>Dia</label>
       <div>
          <input type="text" id="dia" name="dia">                    
       </div>
    
    </form>
    

    Example: Page that processes

    <?php
       $_SESSION["pesquisa"] = $_POST; //ERRO POIS $_POST RETORNA ARRAY
       $_SESSION["pesquisa"] = implode("&",$_POST); //NAO SERVE POIS FICA 2000&03&12
    ?>
    
    <script>
       parent.iframe.location.href = 'mais_infos.php?<?php echo $_SESSION["pesquisa"];?>';
    </script>
    

    I would need my $_SESSION["pesquisa"] to be something like ano=2000&mes=03&dia=12 to be able to complete the URL, but remembering again, the form fields are mounted dynamically.

        
  • asked by anonymous 12.06.2015 / 14:44

    1 answer

    2

    What I understand is what you need to pass data from a form to the iframe dynamically. As the data comes via POST, it would soon come in the format $_POST['nome_campo'] = valor . If you make a

    $variavel = '';
    foreach ($arrayPost as $campo => $valor){
        if (end($arrayPost) != $valor)
            $variavel .= $campo.'='.$valor.'&';
        else
            $variavel .= $campo.'='.$valor;
    }
    

    Make sure that the variable $variavel returns exactly what you want.

        
    12.06.2015 / 15:00