This looks like it will do it.  I haven't tested it, so don't take my word for
it.

<?php
/************************************************************************
 *
 * PostIt - Pretend to be a form.
 *
 * Copyright (c) 1999 Holotech Enterprises. All rights reserved.
 * You may freely modify and use this function for your own purposes. You
 * may freely distribute it, without modification and with this notice
 * and entire header intact.
 *
 * This function takes an associative array and a URL. The array is URL-
 * encoded and then POSTed to the URL. If the request succeeds, the
 * response, if any, is returned in a scalar array. Outputting this is the
 * caller's responsibility; bear in mind that it will include the HTTP
 * headers. If the request fails, an associative array is returned with the
 * elements 'errno' and 'errstr' corresponding to the error number and
 * error message. If you have any questions or comments, please direct
 * them to [EMAIL PROTECTED]
 *
 *                                          Alan Little
 *                                          Holotech Enterprises
 *                                          http://www.holotech.net/
 *                                          December 1999
 *
 ************************************************************************/

  function PostIt($DataStream, $URL) {

//  Strip http:// from the URL if present
    $URL = ereg_replace("^http://";, "", $URL);

//  Separate into Host and URI
    $Host = substr($URL, 0, strpos($URL, "/"));
    $URI = strstr($URL, "/");

//  Form up the request body
    $ReqBody = "";
    while (list($key, $val) = each($DataStream)) {
      if ($ReqBody) $ReqBody.= "&";
      $ReqBody.= $key."=".urlencode($val);
    }
    $ContentLength = strlen($ReqBody);

//  Generate the request header
    $ReqHeader =
      "POST $URI HTTP/1.1\n".
      "Host: $Host\n".
      "User-Agent: PostIt\n".
      "Content-Type: application/x-www-form-urlencoded\n".
      "Content-Length: $ContentLength\n\n".
      "$ReqBody\n";

//  Open the connection to the host
    $socket = fsockopen($Host, 80, &$errno, &$errstr);
    if (!$socket) {
      $Result["errno"] = $errno;
      $Result["errstr"] = $errstr;
      return $Result;
    }
    $idx = 0;
    fputs($socket, $ReqHeader);
    while (!feof($socket)) {
      $Result[$idx++] = fgets($socket, 128);
    }
    return $Result;
  }
?>

Nathan Cook
[EMAIL PROTECTED]
----- Original Message -----
From: "Nathan Cook" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; "Php List" <[EMAIL PROTECTED]>
Sent: Thursday, May 17, 2001 11:54 AM
Subject: Re: Re: [PHP] preprocessing


> In that case you may be able to assemble the headers of a get using the
header()
> function.  I will look up a few more things for you and get back to you after
> lunch! :)
>
> Nathan Cook
> [EMAIL PROTECTED]
>
> ----- Original Message -----
> From: <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Cc: <[EMAIL PROTECTED]>
> Sent: Thursday, May 17, 2001 11:51 AM
> Subject: RE: Re: [PHP] preprocessing
>
>
> >
> > This is a fairly solid suggestion, and it may be what I have to do. But,
> unfortunately, Page C is expecting a POST, not a GET, which may make it not
> work. Also, I would like to avoid this if possible due to some of the
sensitive
> information that will be being passed to and fro. Even if it will be done
using
> SSL.
> >
> > >Try going to the page with the vars you need in the URL.  i.e.:
> > >http://www.www.com/cgi-bin/script?var1=test&var2=testing
> > >If that works then just use a simple header location forward in script 'b':
> > >// process vars....
> >
>header("LOCATION:http://www.www.com/cgi-bin/script?var1=test&var2=testing";);
> > >That way the user will never have to interact with page 'b'.  Note: do not
> start
> > >any output before the header command.
> > >If that doesn't work then there should be some other way of assembling
> cgi-post
> > >headers with the header() function.
> > >Good Luck.
> > >Nathan Cook
> > >[EMAIL PROTECTED]
> > >----- Original Message -----
> > >From: <[EMAIL PROTECTED]>
> > >To: <[EMAIL PROTECTED]>
> > >Sent: Thursday, May 17, 2001 11:18 AM
> > >Subject: [PHP] preprocessing
> > >>
> > >> I have what I feel to be a strange problem (I'm most likely wrong here).
> > >> I have page A, which is an internal page, which posts to page C which is
> > >external (belongs to another company). What I would like is to insert a
> > >preprocessing script (let's call it page b). So, the end result would be,
> users
> > >input data to page a, page a then posts to page b, page b processes all
> > >variables etc and then posts to page c. I don't want the customer, to ever
> > >really have to interact with page b. Is that possible?
> > >> If there is a command to do this, which I must've missed, that would
really
> be
> > >all I need ;)
> > >>
> > >> Louis G
> > >>
> > >> --
> > >> PHP General Mailing List (http://www.php.net/)
> > >> To unsubscribe, e-mail: [EMAIL PROTECTED]
> > >> For additional commands, e-mail: [EMAIL PROTECTED]
> > >> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> > >>
> > >>
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail: [EMAIL PROTECTED]
> >
> >
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to