Jump to content


Photo

$HTTP_REFERER


  • Please log in to reply
2 replies to this topic

#1 koolgirl

koolgirl
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 02 May 2006 - 10:23 PM


Hi again everyone,

I just wanted to start collecting the information about the visitors by myself without depending on 3rd parties to do it for me. So I wrote this:

*************************************************
<?php

$dbcnx = @mysql_connect(

'mysql','login','password');

mysql_select_db("MainDB");

$sql = "INSERT INTO UserRecords SET " .

"IP='$REMOTE_ADDR', " .

"BrowserName='$HTTP_USER_AGENT', " .

"Language='$HTTP_ACCEPT_LANGUAGE', " .

"Referer='$HTTP_REFERER', " .

"Date=CURDATE()";

if (mysql_query($sql)) {

echo("");

} else {

echo("<P>Error processing your request: " .

mysql_error() . "</P>");

}

?>

*****************************************************

Everything works fine with the above code and it updates the fields at the database table correctly. The only field that does not get updated is the Referer field. As far as I know $HTTP_REFERER should take care of it. But it doesn't. Can anyone help me solve the problem? And of course if somebody can suggest which other information should I get if this is not enough?
All help would be Very Very much appreciated



#2 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 02 May 2006 - 10:35 PM

well just so you know, it may be working just fine. from the manual:

'HTTP_REFERER'

The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted.

here is a list of the reserved variables you may wanna look at:

[a href=\"http://us2.php.net/reserved.variables\" target=\"_blank\"]http://us2.php.net/reserved.variables[/a]
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#3 koolgirl

koolgirl
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 02 May 2006 - 11:01 PM


Thanks again Guru,

I got it now and the link that you gave is exactly what I had been looking for.

Have a nice day!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users