in Advanced 

Question preview

HomeQuestion preview:
Log in

How can I display IP of visiting user to my site with PHP ?

I want to be able to store use and display remote IP of users visiting my site. Please tell me how to do this with PHP. Is there a difference if I client is behind a proxy?
Do you know someone who could answer? Ask him for help
Answers: 1
Sort by: date rating
image stenton
13:00/02.01.2008
1.7 from possible 5 with 9 votes
This code snippet displays the real IP of users , even if they are behind a proxy server.

<?php
$ip = isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];
echo 'Your IP is: '.$ip; ?>
Vote:
Please vote! Your opinion matters!
If you haven't found what you've looking for, post a question
Ask question
| Home | Hall of fame | Registration | Log in | Terms of service | Privacy policy | Help | Contacts | RSS |