Send hidden parameters to another page without showing them in URL

0

After doing a search on a form method POST .

<form method="POST" action="../controller/precontBuscaProg.php">
  <input type="date" name="dataini">
</form>

I get on another page what was sent receiving the data like this:

$dataIni = $_POST['dataini'];
$dataFim = $_POST['datafim'];
$dstPost = $_POST['dst'];
$orgPost = $_POST['org'];
$stPost = $_POST['st'];

$objProg = new Prog();
$objProg->setdataoprini($dataIni);
$objProg->setdataoprfim($dataFim);
$objProg->setdest($dstPost);
$objProg->setorig($orgPost);
$objProg->setst1($stPost);

$params= '?'.http_build_query(array('dataini'=> $dataIni, 'datafim'=>$dataFim, 'dst'=> $dstPost, 'org'=> $orgPost, 'st'=> $stPost));
header('location: ../view/programacao.php'. $params);

Return me in the url. Is there any way to hide this in the url?

programacao.php?dataini=2016-08-16&datafim=2016-10-29&dst=%25%25&org=%25%25&st=1

And leave this alone?

programacao.php

If there is another medium besides .htaccess I would like to know.

    
asked by anonymous 30.08.2016 / 15:55

1 answer

-1

Whereas the purpose is unknown and disregarding SEO issues,

Maybe, something that resolves is to store in a session variable.

In this final snippet, instead of building a URL, save to a session variable

$params= '?'.http_build_query(array('dataini'=> $dataIni, 'datafim'=>$dataFim, 'dst'=> $dstPost, 'org'=> $orgPost, 'st'=> $stPost));
header('location: ../view/programacao.php'. $params);

It would look like this

$_SESSION['search'] = array(
    'dataini' => $dataIni,
    'datafim' => $dataFim,
    'dst' => $dstPost,
    'org' => $orgPost,
    'st' => $stPost
);

header('location: ../view/programacao.php?search='. $token);

On the programacao.php page, check for the session according to the search parameter.

if (isset($_SESSION['search'])) {
    $parametros_busca = $_SESSION['search'];
}

I've omitted the session_start () to simplify teaching.

Basic example of how to use session variables:

link

link

obs: Something confusing in your question is that the title points in one direction and the context shows another. In the end I interpreted that it has nothing to do with URL rewrite. Unless you state the opposite more clearly.

    
30.08.2016 / 18:54