i have link like this
<a href="PrintSingleCashier.php?id=<?=$objResult["cashiers_CashierID"]; ?>" target="_new"><img src="../images/print.png"></a>
and i wont to print variable id
to other pages called PrintSingleCashier.php
, i will insert id on link same this PrintSingleCashier.php?id=<?=$objResult["cashiers_CashierID"]; ?>
.
but when go to this page PrintSingleCashier.php
i cannot read id
.
why !!
i read it like $_GET["id"];
but i need read it like $_POST["id"];
You just can't get a $_POST variable trought a link, limited to use $_GET
This is NOT adviced, but anyway, if you must keep it being a $_POST variable to be compatible with previous code or something like that, just do a plain
$_POST["id"] = $_GET["id"]
at the very beginning of your "PrintSingleCashier.php"
Maybe its because of <?=
Try this out
<?php
echo "<a href=\"PrintSingleCashier.php?id=".$objResult["cashiers_CashierID"]."\" target=\"_blank\"><img src=\"../images/print.png\"></a>";
?>
In page PrintSingleCashier.php
read id
as follows
<?php
$id = $_GET['id'];
?>
Ensure array $objResult["cashiers_CashierID"]
has a value.
Good programming practice is that avoid using shortcut tags for PHP.