title: PHP Curl request not working but works fine in POSTMAN
body: <p>I am trying to login to MCA portal ( POST URL : <a href="http://www.mca.gov.in/mcafoportal/loginValidateUser.do" rel="noreferrer">http://www.mca.gov.in/mcafoportal/loginValidateUser.do</a> )</p>
  
  <p>I tried logging in with POSTMAN app on Google Chrome which works fine. However, it doesnt work either in PHP/Python. I am not able to login through PHP/Python</p>
  
  <p>Here is the PHP Code : </p>
  
  <pre><code>$url="http://www.mca.gov.in/mcafoportal/loginValidateUser.do"; 
  
  $post_fields = array();
  
  $post_fields['userNamedenc']='hGJfsdnk`1t';
  $post_fields['passwordenc']='675894242fa9c66939d9fcf4d5c39d1830f4ddb9';
  $post_fields['accessCode'] = ""
  
  $str = call_post_mca($url, $post_fields);
  $str = str_replace("&amp;nbsp;","",$str);   
  
  $dom = new DOMDocument();
  $dom-&gt;loadHTML($str);
  $xpath = new DOMXPath($dom);
  
  $input_id =  '//input[@id="login_accessCode"]/@value';
  $input_val = $xpath-&gt;query($input_id)-&gt;item(0);
  $input_val1 = $input_val-&gt;nodeValue;
  
  $url="http://www.mca.gov.in/mcafoportal/loginValidateUser.do"; 
  
  $post_fields['userNamedenc']='hGJfsdnk`1t';
  $post_fields['passwordenc']='675894242fa9c66939d9fcf4d5c39d1830f4ddb9';
  $post_fields['accessCode'] = $input_val1;  //New Accesscode 
  
  function  call_post_mca($url, $params)
  {   
      #$user_agent = getRandomUserAgent();
      $user_agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36";
      $str = "";
      foreach($params as $key=&gt;$value)
      {
          $str = $str . "$key=$value" . "&amp;";
      }
      $postData = rtrim($str, "&amp;");
  
      $ch = curl_init();  
  
      curl_setopt($ch,CURLOPT_URL,$url);
      curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
      curl_setopt($ch,CURLOPT_HEADER, false); 
      #curl_setopt($ch, CURLOPT_CAINFO, DOC_ROOT . '/includes/cacert.pem');
  
      curl_setopt($ch, CURLOPT_POST, 1);
      curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);   
  
  
      curl_setopt($ch,CURLOPT_USERAGENT, $user_agent);
      curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
      curl_setopt ($ch, CURLOPT_REFERER, $url); 
  
      $cookie= DOC_ROOT . "/cookie.txt";
      curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookie); 
      curl_setopt ($ch, CURLOPT_COOKIEFILE, $cookie); 
  
      $output=curl_exec($ch);
  
      curl_close($ch);
      return $output;
  
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/IUbyX.png" rel="noreferrer"><img src="https://i.stack.imgur.com/IUbyX.png" alt="enter image description here"></a></p>
  
  <p>Any idea what is missing ? </p>