I am trying to transfer 2 parameters idpro and prixprod to the web page ajouter_prix.php. I have been thinking about a problem of concatenation. Where I am running my code, I get only idpro displayed in the URL. Any help please.
Below is my code:
<form action="ajouter_prix.php" method="post">
<tr><td><div>Incrimenter prix: <input type="number" min="1" name="prixprod" value="" size="1" ></div></td></tr>
<?php
echo '<input type="hidden" name="datefin" value="'.$ligne['datea'].'"/>';
echo '<input type="hidden" name="idpro" value="'.$ligne['idpro'].'"/>';
echo '<input type="hidden" name="prix" value="'.$ligne['prix'].'"/>';
echo' <a href="ajouter_prix.php?idpro='.$ligne['idpro'].'"&prixprod="'.$ligne['idpro'].'">Enchérir</a>';
}
?>
</form></div>
take this as an example:
<?php var_dump($_POST); ?>
<form action="#" method="post">
Incrimenter prix: <input type="number" min="1" name="prixprod" value="" size="1" ></div></td></tr>
<?php
echo '<input type="hidden" name="datefin" value="datea"/>';
echo '<input type="hidden" name="idpro" value="idpro"/>';
echo '<input type="hidden" name="prix" value="prix"/>';
echo '<input type="submit" name="submit" value="submit"/>';
?>
</form>
that returns
array (size=4)
'prixprod' => string '' (length=0)
'datefin' => string 'datea' (length=5)
'idpro' => string 'idpro' (length=5)
'prix' => string 'submit' (length=6)
if you want to take the values in a $_GET array you need to change your form method as follows:
<?php var_dump($_GET); ?>
<form action="#" method="get">
<tr><td><div>Incrimenter prix: <input type="number" min="1" name="prixprod" value="" size="1" ></div></td></tr>
<?php
echo '<input type="hidden" name="datefin" value="datea"/>';
echo '<input type="hidden" name="idpro" value="idpro"/>';
echo '<input type="hidden" name="prix" value="prix"/>';
echo '<input type="submit" name="submit" value="submit"/>';
?>
</form>
This will return:
array (size=5)
'prixprod' => string '' (length=0)
'datefin' => string 'datea' (length=5)
'idpro' => string 'idpro' (length=5)
'prix' => string 'prix' (length=4)
'submit' => string 'submit' (length=6)
and you'll have the query string attached to your url:
http://localhost/test.php?prixprod=&datefin=datea&idpro=idpro&prix=prix&submit=submit#
you can take the single values in your ajouter_prix.php
file by something like this:
echo $_POST['datefin']; //for POST method
echo $_GET['datefin']; //for GET method