Page 1 of 1

[SOLVED] IP logging question.

Posted: Tue Mar 16, 2004 5:30 pm
by thor
i was just wondering if anyone knew the PHP code that you use to log IP addresses.
kind of like when i type:
<?php echo $_SERVER['HTTP_USER_AGENT']; ?>
it will display something like:
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6) Gecko/20040206 Firefox/0.8


is there some similar code where it will display the IP of the person looking at it?

if anyone knows it please post it. thanks.

Posted: Tue Mar 16, 2004 5:33 pm
by PrObLeM
$ip = $HTTP_REFERER;
then just add that value to a db and there you go ip == loged :)

Posted: Tue Mar 16, 2004 5:36 pm
by m3mn0n

Code: Select all

<?php
echo '<pre>';
  // will print all $_SERVER vars
  print_r ($_SERVER);
echo '</pre>';
?>

Posted: Tue Mar 16, 2004 6:21 pm
by coreycollins

Code: Select all

$ipaddress = $_ENV["REMOTE_ADDR"];

Posted: Tue Mar 16, 2004 6:56 pm
by tim
$_SERVER["REMOTE_ADDR"];

Posted: Tue Mar 16, 2004 7:14 pm
by wmasterj
seems like not everyone agrees or uses the same - but i can say the one before me works fine :)

Posted: Tue Mar 16, 2004 7:14 pm
by m3mn0n
Incase three times isn't enough...a fourth!

Code: Select all

<?php
$theip = $_SERVER['REMOTE_ADDR'];
?>

Posted: Tue Mar 16, 2004 7:18 pm
by tim
why not kick it up a notch:

Code: Select all

<?php
$ip = "$REMOTE_ADDR";
echo $ip;
?>

Posted: Tue Mar 16, 2004 7:18 pm
by Goowe
Haha, everyone bands together to help someone out! I love this forum :wink:

Doesn't it seem like a lot of people are looking to track IP addresses? :roll:

I hope it's working good for you thor.

Posted: Tue Mar 16, 2004 9:34 pm
by Illusionist
PrObLeM wrote:$ip = $HTTP_REFERER;
then just add that value to a db and there you go ip == loged :)
I really don't think so...
tim wrote:why not kick it up a notch:

Code: Select all

<?php
$ip = "$REMOTE_ADDR";
echo $ip;
?>
would require register_globals to be on .... :?

But i do agree wiht tim's first method of getting the user's IP

Posted: Tue Mar 16, 2004 10:52 pm
by m3mn0n
Illusionist wrote:But i do agree wiht tim's first method of getting the user's IP
Which essentially is exactaly what I posted. :wink:

Posted: Wed Mar 17, 2004 5:17 pm
by tim
i am aware globals has to be turned on, but we were throwing out multiple ways of getting the IP, and $REMOTE_ADDR is for sure a way (globals onn, like you said ill).

kudos

Posted: Wed Mar 17, 2004 7:37 pm
by JAM
It's nice when people edit their posts adding [SOLVED] in the topics when due, but please... Use the english word, and not a 'leet haxxor translated version.

Why? Plain, good curtesy and so that it's easely searchable for those looking for answers. Thanks.

Posted: Wed Mar 17, 2004 8:24 pm
by Illusionist
Sami wrote:Incase three times isn't enough...a fourth!

Code: Select all

<?php
$theip = $_SERVER['REMOTE_ADDR'];
?>
wow! i totally didn't see thsi the first itme i look at this thread. My apologies Sami!

Posted: Thu Mar 18, 2004 7:26 am
by m3mn0n
hehe

No worries dude. :)