Dynadot

Getting current user's IP address

Spaceship
Watch
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:
<?php
$ip = $_ENV["REMOTE_ADDR"]; //set variable

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

?>
I hope somebody finds it helpful.

ASGSOFT
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
If you search for it on google you would easily find it, but thnx anyway.
 
0
•••
Thanks for the information...I was looking for such a info to be used with a Quiz PHP Script!
 
0
•••
I personally uses JS for that :D But I guess PHP overcomes it in simplicity
 
0
•••
Thanks may come in handy..
 
0
•••
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>";
[COLOR=DarkOrange]   echo "REMOTE_ADDR=".getenv("REMOTE_ADDR")."<br>";
[/COLOR]   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.
 
0
•••
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back