title: Error 500 with php curl
body: <p>I'm trying to do a curl that login in one website, the problem is that I keep getting Error 500--Internal Server Error.</p>
  
  <p>Code:</p>
  
  <pre><code>&lt;?php
  $path = $_SERVER["DOCUMENT_ROOT"]."/teste/ctemp";
  
  //login form action url 
  $url="https://example/security_check"; 
  $postinfo = "username=xxx&amp;password=xxxx";
  $website="https://example/account"; 
  $base="https://example/"; 
  
  $cookie_file_path = $path."/cookie.txt";
  
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_HEADER, false);
  curl_setopt($ch, CURLOPT_NOBODY, false);
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  
  curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
  //set the cookie the site has for certain features, this is optional
  curl_setopt($ch, CURLOPT_COOKIE, "cookiename=0");
  curl_setopt($ch, CURLOPT_USERAGENT,
      "Mozilla/5.0 (Windows; U; Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Firefox/45.0");
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_REFERER, $_SERVER['REQUEST_URI']);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  
  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $postinfo);
  
  
  curl_exec($ch);
  
  //page with the content I want to grab
  curl_setopt($ch, CURLOPT_URL, $website);
  //do stuff with the info with DomDocument() etc
  $html = curl_exec($ch);
  curl_close($ch);
  $html = preg_replace("/&lt;head&gt;/i", "&lt;head&gt;&lt;base href='$base' /&gt;", $html, 1); 
  
  echo $html;
  </code></pre>
  
  <p>The website is <a href="https://example/" rel="nofollow">https://example/</a>, the auth form is submited to <a href="https://example/security_check" rel="nofollow">https://example/security_check</a> with post username and password, after a sucessful login, the page is redirected to example/account <br>
  Is there something wrong with my code?</p>