title: How to bypass a login form with PHP and curl?
body: <p>We want to have a unique login form for different Softwares. We wrote a login form to get the username and password and send them to a ASP.Net software using curl and PHP like this:</p>
  
  <pre><code>define("COOKIE_FILE", "cookie.txt");
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL,"http://192.168.100.1/webrest/default.aspx");
  curl_setopt($ch, CURLOPT_COOKIEJAR, COOKIE_FILE); 
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_HTTPHEADER, array('Host: 192.168.100.1'));
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLINFO_HEADER_OUT, true);
  curl_setopt($ch, CURLOPT_POSTFIELDS,
              array(
                  'txtUserName' =&gt; 'user',
                  'txtPassword' =&gt; 'pass',
                  '__VIEWSTATE' =&gt; '/wEPDwUKLTg1ODEyNzU0Mg9kFgICAw9kFgQCDw8PFgIeBFRleHQFMdmH2YTYr9uM2YbaryDYsdi02K8g2b7Yp9uM2K/Yp9ixINin24zYsdin2YbbjNin2YZkZAIRDw8WAh8ABZQB2KrZ',
                  '__VIEWSTATEGENERATOR' =&gt; '',
                  '__EVENTVALIDATION' =&gt; '',
  
              )
  );
  
  
  $server_output = curl_exec ($ch);
  
  echo $server_output;
  curl_close ($ch);
  </code></pre>
  
  <p>But we can't login and get the source of login form again as output without any error!
  Can we get login and then send user to the target page like "<a href="http://192.168.100.1/webrest/reserve.aspx" rel="nofollow noreferrer">http://192.168.100.1/webrest/reserve.aspx</a>"?</p>