title: PHP Post data with Fsockopen
body: <p>I am attempting to post data using fsockopen, and then returning the result.
  Here is my current code:</p>
  
  <pre><code>&lt;?php
  $data="stuff=hoorah\r\n";
  $data=urlencode($data);
  
  $fp = fsockopen("www.website.com", 80, $errno, $errstr, 30);
  if (!$fp) {
      echo "$errstr ($errno)&lt;br /&gt;\n";
  } else {
      $out = "POST /script.php HTTP/1.0\r\n";
      $out .= "Host: www.webste.com\r\n";
      $out .= 'Content-Type: application/x-www-form-urlencoded\r\n';
      $out .= 'Content-Length: ' . strlen($data) . '\r\n\r\n';
      $out .= "Connection: Close\r\n\r\n";
      fwrite($fp, $out);
      while (!feof($fp)) {
          echo fgets($fp, 128);
      }
      fclose($fp);
  }
  ?&gt; 
  </code></pre>
  
  <p>It is supposed to echo the page, and it is echoing the page, but here is the script for script.php</p>
  
  <pre><code>&lt;?php
  echo "&lt;br&gt;&lt;br&gt;";    
  $raw_data = $GLOBALS['HTTP_RAW_POST_DATA'];  
   parse_str( $raw_data, $_POST );
  
  //test 1
  var_dump($raw_data);
  echo "&lt;br&gt;&lt;br&gt;":
  //test 2
  print_r( $_POST );  
  ?&gt;
  </code></pre>
  
  <p>The outcome is:</p>
  
  <blockquote>
    <p>HTTP/1.1 200 OK Date: Tue, 02 Mar 2010
    22:40:46 GMT Server: Apache/2.2.3
    (CentOS) X-Powered-By: PHP/5.2.6
    Content-Length: 31 Connection: close
    Content-Type: text/html; charset=UTF-8
          string(0) "" Array ( )</p>
  </blockquote>
  
  <p>What do I have wrong? Why isn't the variable posting its data?</p>