Send data To another page [duplicate]

-1

Is there a way to send data with php through POST; in the same way that is done through the action of the teg form.

That is, send data from page A to B and be directed to page B accessing that data.

    
asked by anonymous 01.08.2018 / 19:36

2 answers

1

You can use a form full hidden:

Page A:

<b>Variável AA:</b>: <?= $aa ?><br />
<b>Variável AB:</b>: <?= $ab ?><br />
<form action="paginaB.php" method="post">
   <input type="hidden" name="variavel_aa value="<?= $aa ?>">
   <input type="hidden" name="variavel_ab value="<?= $ab ?>">
   <input type="submit" value="PROXIMA">
</form>

Page B:

<b>Variável AA:</b>: <?= $POST['variavel_aa'] ?><br />
<b>Variável AB:</b>: <?= $POST['variavel_aa'] ?><br />
    
02.08.2018 / 14:55
1

You can do this with session variables. On page A:

$_SESSION['variavel'] = 'Valor da variavel';

On page B you capture the passed value:

$var = $_SESSION['variavel'];

Only one thing: at the beginning of the pages that will use this one should put the following:

session_start();
    
01.08.2018 / 21:37