Re: How to post quote/double quote mark?

From: Date: Fri, 10 Dec 2004 01:40:06 +0000
Subject: Re: How to post quote/double quote mark?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-203889@lists.php.net to get a copy of this message
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@php.net) -- http://www.openphp.cn

« previous php.general (#203889) next »