RE: [PHP] Faking a form POST
| From: | .ben | Date: | Tue, 16 Apr 2002 21:24:55 +0000 |
| Subject: | RE: [PHP] Faking a form POST | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-93259@lists.php.net to get a copy of this message | ||
Thanks to everyone who helped out with this question, got it all working
nicely now. Will credit you all on finished site.
Cheers,
.ben
> -----Original Message-----
> From: Steve Dix [mailto:steve@stevedix.de]
> Sent: 16 April 2002 12:26
> To: .ben
> Cc: php-general@lists.php.net
> Subject: RE: [PHP] Faking a form POST
>
>
> On 16 Apr 2002 at 12:22, .ben wrote:
>
> > hmm, i was kinda after an in-process component like the ASP components
> > ASPHTTP (http://www.ServerObjects.com) and ASPTear
> > (http://www.alphasieraapapa.com).
> >
> > cheers tho,
> >
> > .b
> >
>
> Try this :
>
> You will have to encode your data in a similar manner to a get
> method, only without using the ? ie
>
> to send hello = 1, mouse=brown
>
> &hello=1&mouse=brown
>
> in $data_to_send
>
> <?
> function PostToHost($host, $path, $data_to_send)
> {
> $fp = fsockopen($host,80);
> fputs($fp, "POST $path HTTP/1.1\n");
> fputs($fp, "Host: $host\n");
> fputs($fp, "Content-type: application/x-www-form-urlencoded\n");
> fputs($fp, "Content-length: ".strlen($data_to_send)."\n");
> fputs($fp, "Connection: close\n\n");
> fputs($fp, $data_to_send);
> while(!feof($fp))
> {
> echo fgets($fp, 128);
> }
> fclose($fp);
> }
>
> ?>
> Steve Dix>==============================<steve@stevedix.de
> http://www.stevedix.de/
> http://www.snorty.net/
> http://www.mp3.com/simpletons
> http://www.geocities.com/motorcity/2706
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>