title: Pass data from php to python and get result
body: <p>I want to send data from php to python and make some computations. After that I want to send result of that. The problem is I cannot send data from php to python.</p>
  
  <p>python.php
  username is working but shell_exec or python have problem</p>
  
  <pre><code>&lt;?php
  if(isset($_POST["username"])){
  
      $nick = $_POST["username"];
      echo shell_exec("python new.py '$nick'");
  $jsonData = $_POST["prediction" ];
  echo $jsonData;
  }
  ?&gt;
  </code></pre>
  
  <p>new.py
  When I run python it prints C:\wamp\www\MLWebsite\website\new.py but it should be parameter</p>
  
  <pre><code>import pymysql.cursors
  import sys
  import urllib2, urllib
  import requests
  
  x=sys.argv[0]
  print x
  </code></pre>
  
  <p>I want to get some idea about sending result because end of new.py</p>
  
  <pre><code>mydata=[('prediction','BIO')]
  mydata=urllib.urlencode(mydata)
  path='http://localhost/MLWebsite/website/python.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
  </code></pre>
  
  <p>I use Firebug plugin in Firefox and this error is also shown in webpage.</p>
  
  <blockquote>
    <p><br />  ( ! ) Notice: Undefined
    index: prediction in C:\wamp\www\MLWebsite\website\python.php on line
    <i>6</i> Call Stack #TimeMemoryFunctionLocation 10.0006245144{main}( )..\python.php<b>:</b>0 </p>
  </blockquote>