GET values not available when using META redirect

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • RogerInHawaii
    New Member
    • Jun 2007
    • 13

    GET values not available when using META redirect

    Within some PHP code I'm constructing a URL that includes some variables that I want to pass along with the URL. Something like www.MyWebSite.c om/PageTwo.php?Par am1=32. I intend to use this constructed URL within a META tag that will cause it to jump to that page. For example:

    echo '<META http-equiv="refresh" content="0;URL= www.MyWebSite.c om/PageTwo.php?Par am1=32">';

    That works fine. It does indeed jump to that page an dthe parameter is indeed included in the URL when it gets there.

    But how then do I retrieve the values I passed? How do I get that Param1=32?
    I initially thought that this would constitute something comparable to a GET type of form submit, so that the values would be available via the PHP $_GET function ( e.g. $TheParam = $_GET['Param1'] ) but that doesn't work.

    Is there a method for retrieving parameters passed by URL? Or, alternatively, is there a way I can get that META tag to do a GET type submit?
  • ak1dnar
    Recognized Expert Top Contributor
    • Jan 2007
    • 1584

    #2
    These two php scripts are located at http://localhost/test/meta_and_get/ directory. and i executed the files with the expecting results from the second page. first try them without any other coding in it.

    PageOne.php
    [CODE=php]
    <?php echo '<META http-equiv="refresh" content="0;URL= PageTwo.php?Par am1=32">';?>
    // I removed full URL path and just put second page name here :)
    [/CODE]
    PageTwo.php
    [CODE=php]
    <?php
    print 'PageTwo.php get Executed<br>';
    $param = $_GET['Param1'];
    print 'Param 1 is :'.$param;
    ?>

    [/CODE]

    and got this in the screen:
    PageTwo.php get Executed
    Param 1 is :32

    Comment

    • pbmods
      Recognized Expert Expert
      • Apr 2007
      • 5821

      #3
      Changed thread title to better describe the problem.

      Comment

      • RogerInHawaii
        New Member
        • Jun 2007
        • 13

        #4
        ajaxrand ,

        Thanks for trying that out and showing me how to do it.

        In my particular case I am trying to send MULTIPLE parameters at the end of the URL. When I try to do that with something like www.ThePage.com ?a=hello?b=good bye

        and in the receiving page I do $FirstParemeter = $_GET['a'']. What I receive for $FirstParameter is "hello?b=goodby e". It's not splitting the paremeters. Obviously I'm not formatting that correctly, or not using the correct separator between the multiple parameters. How do I do that correctly?

        Comment

        • RogerInHawaii
          New Member
          • Jun 2007
          • 13

          #5
          Oh, I just figured it out. It uses ampersand to separate multiple parameters, not additional question marks.

          All is fine now. Thanks for your help.

          - Roger

          Comment

          • ak1dnar
            Recognized Expert Top Contributor
            • Jan 2007
            • 1584

            #6
            Originally posted by RogerInHawaii
            Oh, I just figured it out. It uses ampersand to separate multiple parameters, not additional question marks.

            All is fine now. Thanks for your help.

            - Roger
            If you post all your codes in your original post i could help you .Sorry i was out of my Box for couple of hours just now read those new posts.Anyway you figured it out. :) well done !. Keep in touch with TSDN.

            -Ajaxrand

            Comment

            Working...