title: Get request domain using php
body: <p>I have problem with getting domain name using <code>HTTP_REFERER.</code>
  The condition is like this:</p>
  
  <p><a href="http://www.example.com" rel="nofollow">http://www.example.com</a> send a curl post to my server. The things is, example.com does not send their url in <code>curl_setopt(CURLOPT_REFERER)</code>. So is it possible on my server side to get their domain name ?</p>
  
  <p>Thanks a lot for helping me</p>
  
  <p>My code so far:</p>
  
  <hr>
  
  <p>on abc.com side</p>
  
  <pre><code>$data = array('username' =&gt; $username ,
                'email' =&gt; $email,
                'phone' =&gt; $phone );
  
      $string = http_build_query($data);
      // For debugging purpose
      // echo $string;
  
      $ch =  curl_init("http://localhost/test/str_pos.php");
      curl_setopt($ch, CURLOPT_POST, true);
      curl_setopt($ch, CURLOPT_POSTFIELDS, $string);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
      curl_exec($ch);
      curl_close($ch);
  
      header("Location: str_pos.php");
  </code></pre>
  
  <hr>
  
  <p>On my server side:</p>
  
  <pre><code>$domain = parse_url($_SERVER['HTTP_REFERER']);
  
      if (isset($domain['host'])) {
  
          echo $domain['host'];
      }
      else{
          echo "No host found";
      }
  </code></pre>