Jump to content

Archived

This topic is now archived and is closed to further replies.

jeboy

About PHP Referrer

Recommended Posts

I write a code that will show up the referers url, I used $HTTP_REFERER, $_SERVER['HTTP_REFERRER'] but it doesnt work. Here's my code:

[color=green][font=Verdana][b]$ref = @$_SERVER["REFERER"];
// try to catch the referrer
if (empty($ref) && !empty($HTTP_REFERER)){
$ref = $HTTP_REFERER;
}
echo 'Your referer to this page is ';
echo $ref;
[/b][/font][/color]

I'd like to use that method for me to track the page in which the visitor used to click the link and the visitor will be redirected back to that page.

Hope you could help me, thanks

Share this post


Link to post
Share on other sites
All you need to know about tracking visitors:
[url=http://www.phparchives.za.org/articles.php?file=13]http://www.phparchives.za.org/articles.php?file=13[/url]


The referer variable is:
<?php

$_SERVER['HTTP_REFERER']

?>

Share this post


Link to post
Share on other sites
[code]
<?php
$host=apache_request_headers();
echo "\$host['Referer'] = {$host['Referer']}\n";
echo "\$_SERVER['HTTP_REFERER'] = {$_SERVER['HTTP_REFERER']}\n";
?>
[/code]

Share this post


Link to post
Share on other sites
Thanks! I use dreamweaver in writing php scripts, when I type the code $_SERVER['HTTP_REFERER'], it auto completes to [color=red][b]HTTP_REFERRER[/b][/color] instead of [color=green][b]HTTP_REFERER[/b][/color].

Share this post


Link to post
Share on other sites
That why most php programmers use notepad lol.

All the best redarrow.

Share this post


Link to post
Share on other sites
Just to note that referals are not reliable - they depend on the previous host using transfers and the client to actually submit the data, which doesn't always happen. :)

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.