2 Variable by header

Asked

Viewed 3,017 times

1

Code:

$notapost = $_POST['nota'];
$cnpjpost = $_POST['cnpj'];

$objCheck = new Check();
$objCheck->setemail($notapost);
$objCheck->setlocal($cnpjpost);

$controller = new Comando($conn);
$controller->ListaDados($objCheck);


header ("location: ../view/FrontTab.php?nota=".$notapost);

I’m passing the $notapost by header as I pass another variable by header ? which in case would be the $cnpjpost.

I don’t know what the syntax would look like.

1 answer

4


The first element of a querystring must have a question mark ? and the other items must have a commercial and &.

header ("location: ../view/FrontTab.php?nota=".$notapost."&cnpjpost=".$cnpjpost);

Or with sprintf()

header(sprintf("location: ../view/FrontTab.php?nota=%s&cnpjpost=%s", $notapost, $cnpjpost));

php has the function http_build_query() that from an array generates querystring.

$params= '?'.http_build_query(array('nota'=> $notapost, 'cnpj'=>cnpjpost));
header('location: ../view/FrontTab.php'. $params);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.