Reputation: 13
I'm passing a value 'name="idUser"' through a Form with POST from pageA to pageB.
Then in pageB I have a query that uses this value for different things, like select, updates, inserts,etc.
Ej: $updateIDU=$_POST["idUser"];
Select * from table where idUser = $updateIDU;
The pageB has a table in a Form that it can be updated (you can add values, with the form you send the values to the database).
After the information is updated to the database i refresh the page with this:
$link="LOCATION:pageB.php?ok=1";
header($link);
The problem is when i refresh the page with that method the querys for the tables crashes with errors:
Notice: Undefined index: idUser in C:\wamp64\www\pageB.php
Can somebody help me fix my problem or is there another way to pass this value (ID) from pageA to pageB without losing it on refresh (updating the form-table)?
Note When I refresh the page (F5) the page dosen't show me any errors, but when I update the table (with the form) it does show me the error.
Upvotes: 0
Views: 63
Reputation: 143
You can have a hidden form field in page b , when ever user lands on page b update the form field .
Upvotes: 0
Reputation: 312
Instead of using Post you can set a cookie to retain data across all the pages. Set cookie using this:
setcookie("TestCookie", $value);
And then access them using this:
$_COOKIE["TestCookie"];
Upvotes: 1