Welcome to WebmasterWorld Guest from 54.196.238.210

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

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

     

digital signage

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



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

Plz Help me anyone?

abushahin

4:54 pm on Nov 30, 2011 (gmt 0)

5+ Year Member



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 ]

abushahin

4:55 pm on Nov 30, 2011 (gmt 0)

5+ Year Member



change second $ip to $referrer or what ever you want to call it.

rocknbil

4:57 pm on Nov 30, 2011 (gmt 0)

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



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.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month