title: Send data to php file from python
body: <p>I am trying to send data from my python file to a php file and show it inside the browser.</p>
  
  <p>I've read the following question: <a href="https://stackoverflow.com/q/4214231/3801533">Sending data using POST in Python to PHP</a> and I am basing my code on the answer of the question.</p>
  
  <p>My python code thus far is :</p>
  
  <pre><code>import urllib2, urllib
  
  def main():
      mydata = [('one', '1'), ('two', '2')]  # The first is the var name the second is the value
      mydata = urllib.urlencode(mydata)
      path = 'http://localhost/test2.php'  # the url you want to POST to
      req = urllib2.Request(path, mydata)
      req.add_header("Content-type", "application/x-www-form-urlencoded")
      page = urllib2.urlopen(req).read()
      print page
  
  
  if __name__ == "__main__":
      main()
  </code></pre>
  
  <p>My php code is: </p>
  
  <pre><code>&lt;meta http-equiv="refresh" content="1" /&gt; &lt;!-- Updates the whole page each second --&gt;
  &lt;?php
  echo $_POST['one'];
  echo "\n";
  echo $_POST['two'];
  ?&gt;
  </code></pre>
  
  <p>I am updating the page but it never shows 1 and 2 in the browser, it does show the 1 and 2 printed in python. Is there a way how I can update the php file so it shows everything I send to it?</p>
  
  <p>Thank you!</p>