As stated, use sessions and as an example.
Sidenote: Consult my "Edit" further below about ?id=?"
in your form.
- Assign a session array to the GET array, then use the same session array for subsequent pages.
The variable names don't really matter, it's the session array that is important here.
First start with, and from the page where you will retrieve the GET array:
session_start();
if(!empty($_GET['id'])){
$ID = $_GET['id'];
}
$_SESSION['id'] = $_GET['id'];
$var_page1 = $_SESSION['id'];
echo "ID #: " . $var_page1;
then on the next page:
session_start();
if(isset($_SESSION['id'])){
$var_page2 = $_SESSION['id'];
echo "ID #: " . $var_page2;
}
and the subsequent page following that:
session_start();
if(isset($_SESSION['id'])){
$var_page3 = $_SESSION['id'];
echo "ID #: " . $var_page3;
}
References:
Sidenote: If your GET array will always be an integer, you can pass (int)
to it for more protection.
$ID = (int)$_GET['id'];
Reference:
Edit: (something I noticed while testing) - I used 123
as an example, being:
$_GET['id'] = 123;
$ID = (int)$_GET['id'];
Your form will need to be adjusted because of ?id=?"
. (the extra ?
and quote).
<form method="post" action="updateorder.php?id=?"<?php echo htmlspecialchars($ID);?>">
^^ extra question mark and quote - delete it
Because that will translate to the following (and in HTML source) which is a ?
and adding an additional quote, which is something you don't want and will fail you.
<form method="post" action="updateorder.php?id=?"123">
It will need to be changed to the following:
<form method="post" action="updateorder.php?id=<?php echo htmlspecialchars($ID);?>">
which will produce the following in HTML source:
<form method="post" action="updateorder.php?id=123">