title: POST in cURL lib with PHP isn't sending
body: <p>I'm trying to send POSTDATA via cURL with PHP and i think post isn't sending</p>
  
  <pre><code>$ch = curl_init();
  curl_setopt($ch, CURLOPT_HEADER, true);
  curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  curl_setopt($ch, CURLINFO_HEADER_OUT, true);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  curl_setopt($ch, CURLOPT_URL, $url);
  $t = curl_exec($ch);
  </code></pre>
  
  <p>Don't know why, but i'm trying to login in a page and when i dump $t, i always see the form, curl_error is empty, what can i do to  debug this? the page trying to login isn't mine!</p>
  
  <hr>
  
  <p>I have a local form emulating cURL and its OK:</p>
  
  <pre><code>&lt;form action="$url" method="POST"&gt;
    &lt;input type="hidden" name="username" value="$uspw" /&gt;
    &lt;input type="hidden" name="password" value="$uspw" /&gt;
    &lt;input type="submit" value="Send" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>It login in the $url! Here is the $data i send to POSTFIELDS in cURL</p>
  
  <pre><code>$data = array('username' =&gt; $uspw,
                'password' =&gt; $uspw);
  </code></pre>
  
  <p>Yes.. the user and password is the same</p>
  
  <hr>
  
  <p>Headers received:</p>
  
  <pre><code>HTTP/1.1 100 Continue
  
  HTTP/1.1 200 OK
  Date: Sun, 25 Nov 2012 05:23:19 GMT
  Server: Apache
  Cache-Control: no-cache="set-cookie"
  Content-Length: 4822
  Set-Cookie: SESSIONID_portalApp=xxxxxx!-xxx!xxx; path=/
  Content-Language: en
  X-Powered-By: Servlet/2.4 JSP/2.0
  Content-Type: text/html; charset=ISO-8859-1
  </code></pre>
  
  <p>and after this i receive all the form, again...</p>
  
  <hr>
  
  <pre><code>$data = array('username' =&gt; $uspw,
      'password' =&gt; $uspw);
  
  
  $header = array('Origin: xxx',
          'Content-Type: application/x-www-form-urlencoded',
          'Connection: keep-alive',
          'Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3',
          'Cache-Control: max-age=0',
          'Except:',
          'Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
          'Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3',
          'Accept-Encoding:gzip,deflate,sdch',
          'Accept-Language:es-ES,es;q=0.8',
          );
  
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_HEADER, 1);
  curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  curl_setopt($ch, CURLINFO_HEADER_OUT, 1);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  
  curl_setopt($ch, CURLOPT_FORBID_REUSE, 0);
  curl_setopt($ch, CURLOPT_FRESH_CONNECT, 0);
  curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
  
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11");
  curl_setopt($ch, CURLOPT_COOKIEJAR, 'xxx.txt');
  curl_setopt($ch, CURLOPT_REFERER, 'xxxx');
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  curl_setopt($ch, CURLOPT_URL, $url);
  $t = curl_exec($ch);
  </code></pre>
  
  <p>Thank You!</p>