title: Can't get Python 3 to transfer POST data to PHP
body: <p>I want to send a simple string from Python 3 to a PHP site that converts it into a .txt file. My entire code looks like this:</p>
  
  <p>Python:</p>
  
  <pre><code>import urllib.parse
  import urllib.request
  
  str1 = "abcdefg"
  
  url = "http://site.net/post.php"
  
  aa = str1.encode('utf-8')
  req = urllib.request.Request(url, aa)
  req.add_header('Content-Type', 'this/that')
  urllib.request.urlopen(req, data=aa)
  </code></pre>
  
  <p>PHP:</p>
  
  <pre><code>&lt;?php
  
  $handle = fopen("/dir/".name.".txt", "w");
  
  $myContent = $_POST[aa];
  
  fwrite($handle, $myContent);
  
  fclose($handle);
  
  ?&gt;
  </code></pre>
  
  <p>Python accesses the site, and a .txt file gets created, except the file is blank. I've tried changing <code>$_POST</code> to <code>$_GET</code> and <code>$_REQUEST</code>, as well as placing single and double quotes around <code>'aa'</code> in various places. I suspect that <code>Python</code> and <code>PHP</code> aren't communicating about the name of the string/data that I want it to interpret.</p>
  
  <blockquote>
    <p>EDIT: This PHP code already handles POST data from another website. The issue only arises with Python compatibility</p>
  </blockquote>