Welcome to WebmasterWorld Guest from 54.196.246.145

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

How I get IP address of client, previous reference page etc ?

     
10:48 am on Nov 30, 2011 (gmt 0)

New User

joined:Oct 14, 2011
posts: 9
votes: 0


How I get IP address of client, previous reference page etc ?

Plz Help me anyone?
4:54 pm on Nov 30, 2011 (gmt 0)

Junior Member

5+ Year Member

joined:Nov 20, 2009
posts: 98
votes: 0


with php it very easy to get user info using the server variables:

for ip:

$ip=$_SERVER['REMOTE_ADDR'];


for Referrer

$ip=$_SERVER['HTTP_REFERER'];


all you need is here and more:

[php.net ]
4:55 pm on Nov 30, 2011 (gmt 0)

Junior Member

5+ Year Member

joined:Nov 20, 2009
posts: 98
votes: 0


change second $ip to $referrer or what ever you want to call it.
4:57 pm on Nov 30, 2011 (gmt 0)

Senior Member

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Nov 28, 2004
posts:7999
votes: 0


Look through the list of $_SERVER [php.net] variables (environment variables in most other languages) or print a phpinfo() to see them.

The referrer is only sent if a link was actually clicked, it is not present in direct requests, and it not all that reliable - only sends if the client (in this case, browser) sends it, which some don't, and can be disabled for security purposes. But in most cases it's useful.

"Client" can mean many things. In web apps, it means the software accessing the resource, which for most of us is a web browser. If you mean your customers, it's a different context.

The remote_addr value will report an IP address, but that IP address is not actually the "client's" computer, it's the IP assigned to the modem by the internet service. It's also unreliable - in may cases these are assigned dynamically, that is, if you restart your modem, the ISP may assign a different IP to the connection. WiFi changes everything too, you can access via different networks easily.
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members