My user request form (Page1) produces a list of data (Page2).
I want to place a button on Page2 that will enable to the user to return to Page1 with the data requests originally selected.
I can use $Server['QueryString'] to get the string of parameters that were passed to call Page2.
This should probably work in an Href, but I can't get it to work in a button.
Two problems, The button wants to send a parameter for the button name (which I could ignore), and second, I can't get the Query_string added properly.
echo '<form method="GET" action="request.php" >';
echo '<button name="Z" value="0"'.$pagequery_string.'>Return</button>';
You can't use query string. Because it's far away from previous page's address.
page1 address should pe passed to page2 using hidden form field. And there should be used still no query string but REQUEST_URI, which actually designated to contain current page address.
Can you provide examples of real page1 and page2 addresses?
echo '<button name="Z" value="0" onclick="document.location=\\'request.php?' . $_SERVER['QUERY_STRING'] . '\\';">Return</button>';
I'm not sure there's any significance to the real web page addresses, we can call them page1 and page2, although I may have confused you in my code sample that refers to the requesting page a request.php.
I think you're wrong about being too far away to use Query_String. I assigned it in page2 as:
$pagequery_string = $Server['QueryString'];
If I then print it as
it displays correctly. So, not too far away.
But when I try to incorporate that into my button it has problems - although I can see the $Get call and it is almost correct.
1. In the redirect to Page1 it is displaying decimal versions of 2 characters - the "=" and the "&".
2. It is also trying to send my button name and value, but is not following with a "&" for the query_string.
Maybe the form automatically converts these characters. Is it possible they will work anyway?
And to Rajug,
I'm not sure there's any significance to the real web page addresses,
Up to you. It is you, who need a solution, not me.