title: I can't log on to a page using curl
body: <p>I need to log on a page using curl to get a value from the page, but I don't get any result at all.
  Have I missed something or is it maybe impossible to implement? </p>
  
  <pre><code>&lt;?
  $u = "******************";
  $p = "******************";
  
  $token = file_get_contents("https://secure.izettle.com/portal/login");
  preg_match('/content=\"(.*?)\" name=\"csrf-token/', $token, $t);
  $authenticity_token = $t[1];
  echo $authenticity_token;
  
  $fields = array("user[email_address]" =&gt; $u, "user[password]" =&gt; $p, "authenticity_token" =&gt; $authenticity_token );
  $ch = curl_init();
  
  //Set curl options
  $options = array(
      CURLOPT_URL =&gt; "https://secure.izettle.com/portal/login",
      CURLOPT_COOKIEJAR =&gt; "cookie.txt",
      CURLOPT_COOKIEFILE =&gt; "cookie.txt",
      CURLOPT_RETURNTRANSFER =&gt; true,
      CURLOPT_POST =&gt; true,
      CURLOPT_POSTFIELDS =&gt; $fields
  );
  
  curl_setopt_array($ch, $options);
  curl_exec($ch);
  curl_setopt($ch, CURLOPT_URL, "https://secure.izettle.com/portal/reports?date=2014-05-21");
  $page = curl_exec($ch);
  
  if(!curl_exec($ch)){
      die('Error: "' . curl_error($ch) . '" - Code: ' . curl_errno($ch));
  }
  
  echo $page.'&lt;br&gt;';
  </code></pre>