Hi ,
I am new to PHP and am self teaching myself. i understand the basics of getting info into a MYsql database, and retrieving it, and how to use variables and arrays. But I am trying to make a script that will grab refers to my site and display them on my website in order from most hits to least hits. I was wondering , what is the code to grab referes from other sites to display the url of the sites, or the name of the sites refereing to my site. I have used code other people have made but I would like to use my own. Any help would be appreciated .
Thanks
Display the top referers on my website
Moderator: General Moderators
Why? To invite spammers to your website?
You can get the referer with $_SERVER['HTTP_REFERER'] but the value isn't always there to be grabbed (not in the header) and I believe it's very easily spoofed.
You can get the referer with $_SERVER['HTTP_REFERER'] but the value isn't always there to be grabbed (not in the header) and I believe it's very easily spoofed.
Actually the top refferes would be displayed on like an admin page so only the admins will see it, but I want to see how people are linking to the site and which sites are actually driving in the traffic. It is for my own knowledge and I will use the info to find out what kind of sites are driving in the most traffic.
So I would use $_SERVER['HTTP_REFERER'] so would I make a variable like $referer = "$_SERVER['HTTP_REFERER']";
and then call teh variable in an echo statement? echo $referer; - Or is there a way to write the refferer to a database and have them display in order from most refered to least refered?
So I would use $_SERVER['HTTP_REFERER'] so would I make a variable like $referer = "$_SERVER['HTTP_REFERER']";
and then call teh variable in an echo statement? echo $referer; - Or is there a way to write the refferer to a database and have them display in order from most refered to least refered?
I seenetpants wrote:Actually the top refferes would be displayed on like an admin page so only the admins will see it, but I want to see how people are linking to the site and which sites are actually driving in the traffic. It is for my own knowledge and I will use the info to find out what kind of sites are driving in the most traffic.
that'snetpants wrote:So I would use $_SERVER['HTTP_REFERER'] so would I make a variable like $referer = "$_SERVER['HTTP_REFERER']";
Code: Select all
$referer = $_SERVER['HTTP_REFERER'];Well of course... store the value and then add it to a table...netpants wrote:and then call teh variable in an echo statement? echo $referer; - Or is there a way to write the refferer to a database and have them display in order from most refered to least refered?
http://www.Yoursite.com/somepage.php:
Code: Select all
$referer = $_SERVER['HTTP_REFERER'];
// If referer != yoursite
// Save referer to databaseCode: Select all
// Load most common referers from db and display them for adminsso something like this?
Code: Select all
if ( $referer != "http://www.mysite.com" )
{
INSERT INTO Referer (refererURL)
VALUES ($referer)
}
else
{
die
}