RE: [PHP] Remote cgi script function
| From: | John Holmes | Date: | Sun, 23 Jun 2002 19:55:42 +0000 |
| Subject: | RE: [PHP] Remote cgi script function | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-103489@lists.php.net to get a copy of this message | ||
> I am new to php, I would like to create a function that when called
> sends text from a text box as a query to a remote cgi script ,e.g
> http://www.anydomain.com/cgi-bin/script.cgi, and return the
> results as
a
> variable so that i can echo the returned variable to an html page.
<?
$contents = "";
$text = "whatever...";
$ftext = urlencode($text);
$fp = fopen("http://www.example.com/cgi-bin/script.cgi?text="
. $ftext,
"r");
while($data = fread($fp,1000))
{ $contents .= $data; }
fclose ($fd);
?>
The response is now in $contents. Adapt to your needs.
---John Holmes...