0
I have a form that is mounted dynamically according to the preferences of each user and is submitted via post to the page that does the process.
In the process page I need, among other things, to load an iframe that will bring extra information, according to the dynamic form information of the first screen.
My problem is right there: how to pass the information to the iframe bring 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 mine $_SESSION["pesquisa"]
something like ano=2000&mes=03&dia=12
to be able to complete the URL, but remembering again, the form fields are mounted dynamically.
You can try using,
serialize
(to store) andunserialize
(to recover).– Rafael Withoeft
@Rafaelwithoeft with the
serialize
my post was something likea:6:{s:8:"indice_9";s:6:"DOC 01";s:9:"indice_10";s:4:"2015";s:9:"indice_11";s:2:"03";s:9:"indice_12";s:1:"1";s
. I wouldn’t have any other choice?– Dirty Old Man
And in the
unserialize
, Did you normally recover the value? Or do you need to be readable on Session?– Rafael Withoeft
Sorry, I had not seen that you wanted to pass the value in the url of iframe, you can also try using the following function:
http_build_query
. Example:http_build_query( ['parametro1' => '123', 'parametro2'=> '123'] )
. And you can test by passing the post directlyhttp_build_query($_POST)
;– Rafael Withoeft
@Rafaelwithoeft also worked with
http_build_query
, only detail is that this function exchanges spaces in the value of the fields by +.– Dirty Old Man