Hi, on Page 1 I am using header("location:page2.php") PHP: and on Page 2 I want to use $_SERVER['HTTP_REFERER'] PHP: to display the page that referred it. However this does not work, I read some on Google that you can use header("referer:page1.php") PHP: to pass the referrer, but it isn't working for me. Any ideas?
I've never been able to rely on the HTTP_REFERER Instead I use a session variable on each page that stores the REQUEST_URI call it $_SESSION['url_back'] or something. Then that session variable should always contain the last page the user was on ... Might work for what you are doing?
Because you can't. The referer is sent by the browser, and not all browsers send it by default. Plus it can be faked/modified by the user. It's nothing to rely on.
Exactly. Some Firewalls and anti-virus software will also strip out the referer. My method by setting a session var on each page to the current page seems to be a valid way to track which page the user last visited though.
hehe test this . i was use this code for change referers of un-natural traffic to natural traffic from search engines and it working fine for me . <?php $host = 'www.yourtargeturl.com'; $service_uri = '/detect_referal.php'; $vars ='additional_option1=yes&additional_option2=un'; $header = "Host: $host\r\n"; $header .= "User-Agent: PHP Script\r\n"; $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; $header .= "Referer: http://www.google.com/search?hl=en&q=jigh&btnG=Google+Search \r\n"; $header .= "Content-Length: ".strlen($vars)."\r\n"; $header .= "Connection: close\r\n\r\n"; $fp = fsockopen("".$host,80, $errno, $errstr); if (!$fp) { echo "$errstr ($errno)<br/>\n"; echo $fp; } else { fputs($fp, "POST $service_uri HTTP/1.1\r\n"); fputs($fp, $header.$vars); fwrite($fp, $out); while (!feof($fp)) { echo fgets($fp, 128); } fclose($fp); } ?> PHP:
you should create detect_referal.php on your own server ( with PHP ) and echo $_SERVER['HTTP_REFERER'] .
someone use my codes and got extra header information on output like this : i work on my codes to hide or pass this codes , post your solution here if you can resolve it sooner .
Try and take away the "echo" because I don't know why it would show any information. EDIT: It actually might be: echo fgets($fp, 128); Code (markup):