On Thursday 06 February 2003 03:39 pm, Kevin Stone wrote:
> All data sent through a POST request is stored in the $_POST array.
>
> $_POST['myvar'];
>
> -Kevin
I know that. That's not what I am asking though.
OK, let me just give a more concrete examples. I browse the archive and found
the following code to simulate a POST request using socket connection. This
will send a request to my own server (localhost). And then, I also have the
second code (included) for /devel/php_post.php, which is the target for this
request.
The problem is, this won't even run. It's just loading and loading. Why?
So basically I need to learn how to handle incoming request similar to this
with PHP.
Thanks a lot
<?
/* This would be the data that needs to be posted to the site - urlencode it
*/
$data ="insert=data&location=here";
/* Headers for http transaction....replace */
$header = "POST /devel/php_post.php HTTP/1.1\r\n". "Accept-Language:
en-us\r\n";
/* Additional info for the receiving server.....optional */
/* This line is *very* important - length of posted data */
$header = $header . "Content-Length: ".strlen($data)."\r\n";
/* Type of content the server can expect from us */
$header = $header . "Content-Type: application/x-www-form-urlencoded\r\n";
$header = $header . "User-Agent: YourCustomUser-Agent (compatible; Linux 2.4;
RedHat 7.2;)\r\n".
"Host: 127.0.0.1\r\n". /* the "host" of the site you are
sending the posted data to.....*/
"$data"; /* this is where the data is sent....no need to
change this line. */
$fp = fsockopen ("127.0.0.1", 80, $errno, $errstr, 30);
if (!$fp)
{
echo "$errstr ($errno)<br>\n";
}
else
{
fputs ($fp, $header);
while (!feof($fp)) {
echo fgets ($fp,128);
}
fclose ($fp);
}
?>
********** This is the code for /devel/php_post.php ****************
<?
// Just wanna know what's going on
echo "BOO";
phpinfo();
?>
>
> ----- Original Message -----
> From: "Reuben D. Budiardja" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Thursday, February 06, 2003 1:27 PM
> Subject: [PHP] Reading input stream of incoming request
>
> > Hi,
> > How do I read an input stream from incoming request in PHP?
> > The incoming input stream is actually an name=value pair of a POST
> > request method from a client.
> >
> > The reason I ask: I am using Apache + PHP as the backend for creating
> > client-server scheme. The client is a MIDlet apps (J2ME:
> > http://java.sun.com/j2me/).
> > The way it sends the name and value parameter for HTTP POST method is by
> > output stream, so I need to read in in php using input stream.
> >
> > Any help on this would be greatly appreciated.
> >
> > Thanks.
> >
> > Reuben D. Budiardja
> >
> > --
> > -------------------------------------------------
> > /"\ ASCII Ribbon Campaign against HTML
> > \ / email and proprietary format
> > X attachments.
> > / \
> > -------------------------------------------------
> > Have you been used by Microsoft today?
> > Choose your life. Choose freedom.
> > Choose LINUX.
> > -------------------------------------------------
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
--
-------------------------------------------------
/"\ ASCII Ribbon Campaign against HTML
\ / email and proprietary format
X attachments.
/ \
-------------------------------------------------
Have you been used by Microsoft today?
Choose your life. Choose freedom.
Choose LINUX.
-------------------------------------------------
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php