curl - Get request domain using php -


i have problem getting domain name using http_referer. condition this:

http://www.example.com send curl post server. things is, example.com not send url in curl_setopt(curlopt_referer). possible on server side domain name ?

thanks lot helping me

my code far:


on abc.com side

$data = array('username' => $username ,               'email' => $email,               'phone' => $phone );      $string = http_build_query($data);     // 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"); 

on server side:

$domain = parse_url($_server['http_referer']);      if (isset($domain['host'])) {          echo $domain['host'];     }     else{         echo "no host found";     } 

i advise different command. instead of http_referer try http_host or server_name.

example:

$domain = parse_url($_server['http_host']);

$domain = parse_url($_server['server_name']);


http_referer - address of page (if any) referred user agent current page. set user agent. not user agents set this, , provide ability modify http_referer feature. in short, cannot trusted.

source http://php.net/manual/en/reserved.variables.server.php

check out following threads here , here.


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -