Re: transfer coding

From: Date: Tue, 21 Sep 2004 10:41:24 +0000
Subject: Re: transfer coding
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-197399@lists.php.net to get a copy of this message
Qt wrote:
Dear Sirs, I gave a post problem and can't solve last a couple of weeks. Todays I come some point but need to ask some thing. I have a destination server and configured to receive some datas. Owner of the server gives the same name of the different data. His idea is that let the internet explorer encode same name data and send to his server with following code; <tr>
          <td>Data 1:</td>
          <td><input type="text" name="data" ></td>
        </tr>
        <tr>
          <td>Data 2:</td>
          <td><input type="text" name="data" ></td>
        </tr>
        <tr>
          <td>Data 3:</td>
          <td><input type="text" name="data" ></td>
        </tr>
As you see, three field has the same name as "data" When I use this html with internet explorer, I have no problem to post data. But when I use following post method, I can not send data. I think I need to do something more for message transfer coding such as use some charecter between same data to let destination server understand. I try to find some solution from HTTP Messages - RFC2616 but no result. Any idea? $str = "data=$data1|$data2|$data3";
    $p = "POST /httppp/servlet/ppp HTTP/1.0\r\n";
$p.= "Host: 152.31.228.206\r\n"; $p.= "Content-type: application/x-www-form-urlencoded\r\n"; //$p .= "\r\n"; //erorr $p.= "Content-length: $len\r\n"; $p.= "\r\n"; $p.= "$str\r\n"; // $p.= "\r\n"; $server = "152.31.228.206"; $connection_timeout = 10; $fp = fsockopen ($server, 80, &$errno, &$errstr, $connection_timeout); actually, specifying the same name for all 3 just makes PHP overwrite the string each time it notices a new one. So you'll only recieve one of those 3 data fields. Easiest to get around that is to call them each "data[]". That will cause PHP to interpret it as an array, and you'll have all your data stored in $_POST['data'][0], $_POST['data'][1] and $_POST['data'][2].


« previous php.general (#197399) next »