Redirecting with POST content

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • David E. Smith

    Redirecting with POST content

    I want to redirect input from one page to another, but it's POST content.
    If it were GET, I could just do something like:
    header("Locatio n: /new/form.php?a=1&b= 2")

    I can't rewrite the destination script, because it's proprietary. And
    compiled. And for Windows.

    A few details might help: I'm using Imail's Web-based email interface on
    one site, and the only form inputs available to it are username and
    password. The existing form looks like this:

    <FORM ACTION="http://dom.ain:8383/login.cgi" METHOD="POST">
    <INPUT TYPE="hidden" NAME="page" VALUE="login">
    Username: <INPUT TYPE="text" NAME="userid">
    Password: <INPUT TYPE="password" NAME="passwd">
    <INPUT TYPE="SUBMIT" VALUE="Login">

    (Obviously, I've stripped out some of the extraneous HTML markup.)

    What I'd like to do is:

    * Modify that form so that it POSTs to some hypothetical "login.php" page
    * Add an INPUT TYPE="CHECKBOX" NAME="SSL" CHECKED

    And have this hypothetical login.php act on the SSL variable, like this
    pseudocode:

    if((isset($_POS T["SSL"])) && ($_POST["SSL"] == TRUE)) {
    redirect (https://dom.ain:8384/);
    }
    redirect (http://dom.ain:8383);

    Where redirect() is some fictitious function that would have to handle
    the other two POSTed variables.

    Again, if the destination form accepted GET, this would be trivial. It'd
    just be a matter of constructing a destination URL and sending a
    Location: header.

    But I'm not sure how to put all this together with POST, or if it's even
    possible.

    So, is it possible? Any pointers? I googled this, and found a number of
    people asking basically this question, but no good answers.

    Thanks!
    ....dave
  • Pedro Graca

    #2
    Re: Redirecting with POST content

    David E. Smith wrote:[color=blue]
    > I want to redirect input from one page to another, but it's POST content.[/color]
    (snip)[color=blue]
    > But I'm not sure how to put all this together with POST, or if it's even
    > possible.
    >
    > So, is it possible? Any pointers? I googled this, and found a number of
    > people asking basically this question, but no good answers.[/color]

    PHP can POST the data to wherever you want (among other options with
    CURL [ http://www.php.net/curl ]), but that is POSTing by the server,
    not the client. If you want the client to do that, it might be possible
    to achieve with JavaScript.

    Once the server POSTs the data and receives some feedback, you can send
    that feedback to the user.


    So you send a form to the client that posts to your server.
    Your server (re)posts that data (possible changed/augmented) to another
    script and gets the result page.
    This result page is then sent to your client who is yet waiting for an
    answer for her POST to your server.

    Makes sense?
    --
    --= my mail box only accepts =--
    --= Content-Type: text/plain =--
    --= Size below 10001 bytes =--

    Comment

    • John Dunlop

      #3
      Re: Redirecting with POST content

      David E. Smith wrote:
      [color=blue]
      > I want to redirect input from one page to another, but it's POST content.[/color]

      You'll have seen this, but I'm posting it for others' sake:



      --
      Jock

      Comment

      • Savut

        #4
        Re: Redirecting with POST content

        Use Javascript, recreate the form on a blank page with all value filled
        using php. then use the js function :
        document.formna me.submit() at the end of the page, the form is now
        automatically submitted when the page is loaded.

        Savut

        "David E. Smith" <dave@technopag an.org> wrote in message
        news:Xns949390F 4D4FC4bureau42@ 127.0.0.1...[color=blue]
        > I want to redirect input from one page to another, but it's POST content.
        > If it were GET, I could just do something like:
        > header("Locatio n: /new/form.php?a=1&b= 2")
        >
        > I can't rewrite the destination script, because it's proprietary. And
        > compiled. And for Windows.
        >
        > A few details might help: I'm using Imail's Web-based email interface on
        > one site, and the only form inputs available to it are username and
        > password. The existing form looks like this:
        >
        > <FORM ACTION="http://dom.ain:8383/login.cgi" METHOD="POST">
        > <INPUT TYPE="hidden" NAME="page" VALUE="login">
        > Username: <INPUT TYPE="text" NAME="userid">
        > Password: <INPUT TYPE="password" NAME="passwd">
        > <INPUT TYPE="SUBMIT" VALUE="Login">
        >
        > (Obviously, I've stripped out some of the extraneous HTML markup.)
        >
        > What I'd like to do is:
        >
        > * Modify that form so that it POSTs to some hypothetical "login.php" page
        > * Add an INPUT TYPE="CHECKBOX" NAME="SSL" CHECKED
        >
        > And have this hypothetical login.php act on the SSL variable, like this
        > pseudocode:
        >
        > if((isset($_POS T["SSL"])) && ($_POST["SSL"] == TRUE)) {
        > redirect (https://dom.ain:8384/);
        > }
        > redirect (http://dom.ain:8383);
        >
        > Where redirect() is some fictitious function that would have to handle
        > the other two POSTed variables.
        >
        > Again, if the destination form accepted GET, this would be trivial. It'd
        > just be a matter of constructing a destination URL and sending a
        > Location: header.
        >
        > But I'm not sure how to put all this together with POST, or if it's even
        > possible.
        >
        > So, is it possible? Any pointers? I googled this, and found a number of
        > people asking basically this question, but no good answers.
        >
        > Thanks!
        > ...dave[/color]

        Comment

        Working...