title: Sending and receiving $_POST through curl
body: <p>I am trying to write a simplified middle-tier that forwards $_POST received from front end and returns response received from the server side.</p>
  
  <p>Following is my php for sending $_POST:</p>
  
  <pre><code>&lt;?php
  $username= 'testuser';
  $password = '123' ;
  $fields = array('username' =&gt; $username, 'password' =&gt; $password);
  echo 'hello world' ; //checking
  $url = 'url';
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  $result = curl_exec($ch);
  curl_close($ch);
  echo $result;
  ?&gt;
  </code></pre>
  
  <p>And this is the php file that receives the curl and just echoes back $_POST(for checking if it is received correctly).</p>
  
  <pre><code>&lt;?php
  
  if (isset($_POST["username"]) &amp;&amp; !empty($_POST["username"])) {
      echo $_POST["username"];}
  
  if (isset($_POST["password"]) &amp;&amp; !empty($_POST["password"])) {
      echo $_POST["password"];}
  
  ?&gt;
  </code></pre>
  
  <p>When i run this on my web server, I just get "Hello world" back. What do I need to change in order to get the response username/password back ?</p>