title: PHP cURL No Error but not working
body: <p>I've been banging my head on this for a while now and I'm sorta fed up. I'm not a PHP programmer so I might be missing something that is not immediately obvious to my Python infused brain.</p>
  
  <p>So here's the context. I need to write a script to login automatically into a web interface and run a search, and well, absolutely everything I've tried to do seems to fail miserably. </p>
  
  <p>Here's my code:</p>
  
  <pre><code>&lt;?php
  echo 'start';
  // INIT CURL
  $ch = curl_init();
  
  // SET URL FOR THE POST FORM LOGIN
  curl_setopt($ch, CURLOPT_URL, 'https://W0110DcIpsOcsRpt02/si_ocs_gui/login.php');
  
  // ENABLE HTTP POST
  curl_setopt ($ch, CURLOPT_POST, 1);
  
  // SET POST PARAMETERS : FORM VALUES FOR EACH FIELD
  
  curl_setopt ($ch, CURLOPT_POSTFIELDS, 'username=*****&amp;password=*****&amp;btnSubmit=Login');
  
  // IMITATE CLASSIC BROWSER'S BEHAVIOUR : HANDLE COOKIES
  curl_setopt ($ch, CURLOPT_COOKIEJAR, '/var/tmp/cookie.txt');
  
  # Setting CURLOPT_RETURNTRANSFER variable to 1 will force cURL
  # not to print out the results of its query.
  # Instead, it will return the results as a string return value
  # from curl_exec() instead of the usual true/false.
  curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
  curl_setopt ($ch, CURLOPT_FRESH_CONNECT, 1);
  
  // EXECUTE 1st REQUEST (FORM LOGIN)
  $store = curl_exec ($ch);
  
  if($store == False){
          echo " store false ";
          echo curl_error($ch);
  } else {
          echo " store true ";
          echo $store;
  }
  
  // SET FILE TO DOWNLOAD
  echo ' second_request ';
  curl_setopt($ch, CURLOPT_URL, 'https://W0110DcIpsOcsRpt02/si_ocs_gui/FWOCS1_BL_SUBSCRIBERS_list.php');
  curl_setopt ($ch, CURLOPT_POST, 1);
  #curl_setopt ($ch, CURLOPT_POSTFIELDS, 'value_ACCESS_NO_4=15142351150');
  curl_setopt ($ch, CURLOPT_POSTFIELDS, 'q=\(SUBSCRIBER_ID~equals~1545303\)');
  // EXECUTE 2nd REQUEST (FILE DOWNLOAD)
  if(!$store == False){
          $content = curl_exec ($ch);
          echo $content;
  }
  // CLOSE CURL
  
  curl_close($ch);
  
  echo ' done';
  ?&gt;
  </code></pre>
  
  <p>The behaviour of this is as follows. I run the script, and it fails at the first cURL request (the login) and returns no errors. I have modified this line here:</p>
  
  <pre><code>curl_setopt ($ch, CURLOPT_POSTFIELDS, 'username=*****&amp;password=*****&amp;btnSubmit=Login');
  </code></pre>
  
  <p>by removing the <code>btnSubmit=Login</code> part and I get the login page displayed with the filled in username and password fields. I can press the login button and it will work. However, it seems that my lack of web development is biting me here and I have no idea how that button works. So, here's the code inspected with firebug:</p>
  
  <pre><code>&lt;a class="rnr-button main" href="#" onclick="document.forms[0].submit();return false;"&gt;Submit&lt;/a&gt;
  </code></pre>
  
  <p>I also went directly in the PHP code on the web server and found the button corresponding to it:</p>
  
  <pre><code>if ((@$_POST["btnSubmit"] == "Login" || $adSubmit) &amp;&amp; $logacc)
  </code></pre>
  
  <p>Hence why I was trying the <code>btnSubmit=Login</code>.</p>
  
  <p>So my question is pretty simple: what am I doing wrong and how can I get the results I need?</p>