homepage Welcome to WebmasterWorld Guest from 50.17.21.7
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

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




msg:4392405
 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




msg:4392562
 4:54 pm on Nov 30, 2011 (gmt 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 ]

abushahin




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

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

rocknbil




msg:4392566
 4:57 pm on Nov 30, 2011 (gmt 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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved