Button Redirect with Query_String

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[‘Query_String’] 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>’;
echo ‘</form>’;

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?

Use JavaScript like this:

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[‘Query_String’];
If I then print it as
echo $pagequery_string;
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,
We already have html and php here. I think we should be able to do this without resorting to javascript. Although I’m tempted by Onclick, it seems like more than should be required to use a button component. Otherwise, why am I using a button?

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.