NamePros.Com (http://www.namepros.com/)
-   Webmaster Tutorials (http://www.namepros.com/webmaster-tutorials/)
-   -   Getting current user's IP address (http://www.namepros.com/webmaster-tutorials/173494-getting-current-users-ip-address.html)

asgsoft 03-04-2006 01:38 PM

Getting current user's IP address
 
While looking in the PHP predefined variables i found an intersting one: $_ENV["REMOTE_ADDR"]. what this does is it gives the current IP of the person viewing your site. This is quite good if you are making a poll for a intranet where each user has their own username.

Have a look at this and tell me what you think.

PHP Code:
<?php
$ip
= $_ENV["REMOTE_ADDR"]; //set variable

echo $ip; //show the value of the variable

?>

I hope somebody finds it helpful.

ASGSOFT

JuggernautH 03-06-2006 04:10 AM

If you search for it on google you would easily find it, but thnx anyway.

navjotjsingh 03-09-2006 10:58 AM

Thanks for the information...I was looking for such a info to be used with a Quiz PHP Script!

leviathon 03-14-2006 07:44 AM

I personally uses JS for that :D But I guess PHP overcomes it in simplicity

Bill 03-14-2006 08:01 AM

You can also display the users IP to them. An example of this can be found at www.cat5.us

J4m!3 03-15-2006 03:58 AM

Thanks may come in handy..

2knew 03-18-2006 01:11 PM

Slightly different method, same info:
Code:
<?php echo "<html><head><title>lifted from www.scanmybrowser.com</title></head>"; echo "<body><h1>A few request header variables:</h1>"; echo "HTTP_REFERER=".getenv("HTTP_REFERER")."<br>"; echo "REMOTE_ADDR=".getenv("REMOTE_ADDR")."<br>"; echo "HTTP_USER_AGENT=".getenv("HTTP_USER_AGENT")."<br>"; echo "HTTP_ACCEPT=".getenv("HTTP_ACCEPT")."<br>"; echo "HTTP_ACCEPT_LANGUAGE=".getenv("HTTP_ACCEPT_LANGUAGE")."<br>"; echo "HTTP_ACCEPT_CHARSET=".getenv("HTTP_ACCEPT_CHARSET")."<br>"; echo "HTTP_ACCEPT_ENCODING=".getenv("HTTP_ACCEPT_ENCODING")."<br>"; echo "</body></html>"; ?>


Similar examples in ASP and C++ at www.scanmybrowser.com - look for the links in the left navbar.


All times are GMT -7. The time now is 02:24 PM.
Site Sponsors
Advertise your business at NamePros

Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0