title: Curl - Cannot retreive hidden input field value
body: <p>I am trying to extract the CSRF-token from a website to enable auto-login for my members on that page through credentials that I am sending via a POST-request. Unfortunately, that token is contained in the value of a hidden input field with the name &quot;__csrf_token&quot;.</p>
  <p>I have used the following code to successfully extract the value of the input field with the name &quot;email&quot;, however when I use it on the above mentioned token field it just doesn't return a value.</p>
  <pre><code>&lt;?php
  
  $ch = curl_init(&quot;https://www.example.com/login.php&quot;);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
  $response = curl_exec($ch);
  
  $dom = new DOMDocument;
  libxml_use_internal_errors(true);
  $dom-&gt;loadHTML($response);
  $tags = $dom-&gt;getElementsByTagName('input');
  for($i = 0; $i &lt; $tags-&gt;length; $i++) {
      $grab = $tags-&gt;item($i);
      if($grab-&gt;getAttribute('name') === '__csrf_token') {
          $token = $grab-&gt;getAttribute('value');
      }
  }
  echo $token;
  ?&gt;
  </code></pre>
  <p>Do you have any idea why the search for the mentioned name doesn't return a value?</p>
  <p>Thanks! (Edit: Typo)</p>