Redirecting with POST content

From: David E. Smith (dave_at_technopagan.org)
Date: 02/18/04


Date: Wed, 18 Feb 2004 20:09:40 -0000

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("Location: /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($_POST["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