[vox-tech] Question about php settings and passing form data

Troy Arnold vox-tech@lists.lugod.org
Wed, 5 Feb 2003 03:56:00 -0800


On Tue, Feb 04, 2003 at 10:58:17PM -0800, ME wrote:
> Troy Arnold said:
> > On Tue, Feb 04, 2003 at 06:06:49PM -0800, ME wrote:
> >> Hello,
> >>
> >> I want to use a php redirector
> >> header('Location: http://website.nofun/redirect.....)
> >> and I want to pass to the page ref-ed in the URI a number of FORM
> >> variables.
> >>
> >> However, I am meeting with little luck on this.
> >>
> >> If I encode the variables as part of the URL with "&" as a separator, I
> >> dcan get the form data and variables that store them (names) to pass
> >> through to the page.
> >
> > Clarifying, you *can* get the above to work as it should?
> 
> Yes, the above is a method for passing form data within the URL. Of course
> this is undesirable for things like passwords, and authentication strings.
> Cookies might be better, but that assumes the form can me set to use them,
> and I dont have access to modify that.

Ahhh, so what you want is to redirect, sending your var/value pairs as
POST data?  Without access to the destination page, any session data you
create is useless, 'cause, 1) like I mentioned before, sess. data is not
passed with the request and 2) the dest. page needs to know about the
session.  

Now, you can probably do this by opening a socket directly.
Something like:

$vars="fname=Mike&Last=Egan";
$s=fsockopen($host, 80);
fputs($s, "POST /some/file.html HTTP/1.1\r\n");
fputs($s, "host: example.com\r\n");
fputs($s, "content-type: application/x-www-form-urlencoded\r\n");
fputs($s, "content-length: " . strlen($vars)."\r\n");
fputs($s, $vars); #or urlencode($vars) , not sure.

See the "network funcs" section of the php manual
For an OO interface, see the HTTP/Request.php PEAR module.
http://pear.php.net/

Actually, that will probably work better, but I already typed the
above... :)

> An ideal solution would be a complement to the header directive that
> permits me to encode arbitrary header information. If I had access to
> this, then I could manually encode the form data through header data, or
> perhaps a way to force certain data to pass as html FORM data. However, it
> seems many of the low-level controls that I am familiar with using are not
> there. Certainly, many of the more complex things seem easier to code for
> the web in php, but the control with respect to granularity is missing as
> a cost of this easy to use, productive environment.

I don't think it's all missing, you just haven't learned where to look
yet. :)  It may be possible to accomplish this with the appropriate
calls to header() and perhaps some output buffering.  See "Output
Control Functions" in php manual.  Might be cajoled into working, not
sure though.

> > Also, the php function phpinfo() can be useful for debugging.
> >
> > Did I understand your problem correctly?  If not, please clarify.
> 
> I'll play with phpinfo() to see if it offers me more than my present
> solution.

It will be a complement to, not a replacement for.  You'll see :) , tons
of cool/useful stuff about the server and php setup, etc. which is not
available through the environment or form variables.  

-troy