php header() help

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • bob

    php header() help

    I use the following code to redirect the browser on an error,
    header("locatio n:error.php");
    exit;

    Is it possible to pass POST variables on as if a form was submitted, using
    header()?

    Thanks for your help,

    Ben.


  • Guest's Avatar

    #2
    Re: php header() help


    "bob" <spam@wrathofth ebarclay.co.uk> wrote in message
    news:3fcfd20b$0 $99737$65c69314 @mercury.nildra m.net...[color=blue]
    > I use the following code to redirect the browser on an error,
    > header("locatio n:error.php");
    > exit;
    >
    > Is it possible to pass POST variables on as if a form was submitted, using
    > header()?
    >
    > Thanks for your help,
    >
    > Ben.
    >
    >[/color]

    I suppose, if you wanted to turn them into GET vars.
    You could do something like this...

    <?
    $url = "error.php? ";
    while(list($key , $value) = each($HTTP_POST _VARS))
    $url .= $key . "=" . $value . "&";
    header("Locatio n: $url");
    ?>





    Comment

    • Chung Leong

      #3
      Re: php header() help

      Use the status code 307.

      header("HTTP/1.0 307 Temporary Redirect");
      header("Locatio n: error.php");

      Uzytkownik "bob" <spam@wrathofth ebarclay.co.uk> napisal w wiadomosci
      news:3fcfd20b$0 $99737$65c69314 @mercury.nildra m.net...[color=blue]
      > I use the following code to redirect the browser on an error,
      > header("locatio n:error.php");
      > exit;
      >
      > Is it possible to pass POST variables on as if a form was submitted, using
      > header()?
      >
      > Thanks for your help,
      >
      > Ben.
      >
      >[/color]


      Comment

      • FLEB

        #4
        Re: php header() help

        Regarding this well-known quote, often attributed to bob's famous "Fri, 5
        Dec 2003 00:32:11 -0000" speech:
        [color=blue]
        > I use the following code to redirect the browser on an error,
        > header("locatio n:error.php");
        > exit;
        >
        > Is it possible to pass POST variables on as if a form was submitted, using
        > header()?
        >
        > Thanks for your help,
        >
        > Ben.[/color]

        You could GET, I imagine, by using something like--

        Location: error.php?error =404

        --but I imagine POSTing is out of the question...

        Or, are you asking if POSTed variables, POSTed to a page that errors out,
        can be preserved? That, I'm not sure... I'll have to check on that...
        there'd be some interesting processing ideas there, I imagine.

        --
        -- Rudy Fleminger
        -- sp@mmers.and.ev il.ones.will.bo w-down-to.us
        (put "Hey!" in the Subject line for priority processing!)
        -- http://www.pixelsaredead.com

        Comment

        • Alvaro G Vicario

          #5
          Re: php header() help

          *** bob wrote/escribió (Fri, 5 Dec 2003 00:32:11 -0000):[color=blue]
          > I use the following code to redirect the browser on an error,
          > header("locatio n:error.php");
          > exit;
          >
          > Is it possible to pass POST variables on as if a form was submitted, using
          > header()?[/color]

          You can process POST data normally in the document where you've placed
          header() function. However, you can't send feedback to browser. If you
          need so you should pass GET data to the redirected page:

          $name=trim($_PO ST['name']);
          $result=insert_ name_into_datab ase($name);
          header('Locatio n: http://www.site.com/error.php?resul t='.urlencode($ result));
          exit;


          --
          --
          -- Álvaro G. Vicario - Burgos, Spain
          --

          Comment

          • Johan Holst Nielsen

            #6
            Re: php header() help

            bob wrote:
            [color=blue]
            > I use the following code to redirect the browser on an error,
            > header("locatio n:error.php");
            > exit;
            >
            > Is it possible to pass POST variables on as if a form was submitted, using
            > header()?[/color]

            PEAR are your friend in this case :)



            Otherwise you can find a class to do HTTP Post requests at:


            Regards,
            Johan

            Comment

            Working...