Hi, 

I used the following function to post a string variable "abcdef" to a PHP 
program on another host: 
<?php
        function PostToHost($host, $path, $data_to_send) {
                $fp = fsockopen($host,80);

                if(!$fp) { 
                        echo "Failed to open port"; 
                        exit; 
                } 
                
                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\n");

                $res = "";
                while(!feof($fp)) {
                $res .= fgets($fp, 128);
                }
                
                fclose($fp);

                return $res;
        }

     $x = "A = \"abcdef\"";
     $y= PostToHost02("host/name", "/path/to/test.php", $x);
     echo $y;

?>

"/path/to/test.php" on "host/name" is as follows.
<?php
    echo $_POST['A']; 
?>

It seemed that test.php got \"abcdef\", instead of "abcdef". Could anyone 
please tell me how to pass "abcdef" to test.php?
Thanks in advance.

-Minghua



Reply via email to