SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2009
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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>';

  2. #2
    Non-Member
    Join Date
    Oct 2009
    Posts
    1,852
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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?

  3. #3
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use JavaScript like this:
    PHP Code:
    echo '<button name="Z" value="0" onclick="document.location=\'request.php?' $_SERVER['QUERY_STRING'] . '\';">Return</button>'
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  4. #4
    SitePoint Enthusiast
    Join Date
    Mar 2009
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    SN5,
    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?

  5. #5
    Non-Member
    Join Date
    Oct 2009
    Posts
    1,852
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •