Re: How to post quote/double quote mark?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi, because your magic_quotes_gpc = on, so, do this:
$A = stripslashes($_POST['A']);
here is a function I use , maybe useful for you:

    function returnInfo($info) {
    	if (!get_magic_quotes_gpc()) {
        	if (is_array($info)) {
        	    $info = array_map("trim", $info);
        	    return array_map("htmlspecialchars", $info);
            } else {
                return htmlspecialchars(trim($info));
            }
        } else {
            if (is_array($info)) {
                $info = array_map("trim", $info);
        	    $info = array_map("htmlspecialchars", $info);
        	    return array_map("stripslashes", $info);
            } else {
                return stripslashes(htmlspecialchars(trim($info)));
            }
        }
    }


Minghua Yao wrote:
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






--
-- ShenKong (shenkong@xxxxxxx)
-- http://www.openphp.cn

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux