[SOLVED] IP logging question.
Moderator: General Moderators
[SOLVED] IP logging question.
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.
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.
Code: Select all
<?php
echo '<pre>';
// will print all $_SERVER vars
print_r ($_SERVER);
echo '</pre>';
?>-
coreycollins
- Forum Commoner
- Posts: 67
- Joined: Sun Feb 01, 2004 1:04 pm
- Location: Michigan
Code: Select all
$ipaddress = $_ENV["REMOTE_ADDR"];Incase three times isn't enough...a fourth!
Code: Select all
<?php
$theip = $_SERVER['REMOTE_ADDR'];
?>why not kick it up a notch:
Code: Select all
<?php
$ip = "$REMOTE_ADDR";
echo $ip;
?>-
Illusionist
- Forum Regular
- Posts: 903
- Joined: Mon Jan 12, 2004 9:32 pm
I really don't think so...PrObLeM wrote:$ip = $HTTP_REFERER;
then just add that value to a db and there you go ip == loged
would require register_globals to be on ....tim wrote:why not kick it up a notch:
Code: Select all
<?php $ip = "$REMOTE_ADDR"; echo $ip; ?>
But i do agree wiht tim's first method of getting the user's IP
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
kudos
Last edited by tim on Wed Mar 17, 2004 8:55 pm, edited 1 time in total.
-
Illusionist
- Forum Regular
- Posts: 903
- Joined: Mon Jan 12, 2004 9:32 pm
wow! i totally didn't see thsi the first itme i look at this thread. My apologies Sami!Sami wrote:Incase three times isn't enough...a fourth!
Code: Select all
<?php $theip = $_SERVER['REMOTE_ADDR']; ?>