The answer to your IT questions
 

Advanced search  • Search tips
My QUESTIONS & ANSWERS
 Question:

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

User Asked by: xpert
Published on: 11:00/02.01.2008
Status: OPEN
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?
 Answers: 1
Sort by: /\ date | rating
Image Answer by: stenton
Posted on: 11:00/02.01.2008
Rating: 1.8 from possible 5 with 8 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
  
| Home | Hall of fame | Register | Log in | Terms of service | Help | Contacts |