NameSilo

Getting current user's IP address

SpaceshipSpaceship
SpaceshipSpaceship
SpaceshipSpaceship
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
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
If you search for it on google you would easily find it, but thnx anyway.
 
0
Close
Thanks for the information...I was looking for such a info to be used with a Quiz PHP Script!
 
0
Close
I personally uses JS for that :D But I guess PHP overcomes it in simplicity
 
0
Close
Thanks may come in handy..
 
0
Close
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
Close
DomainEasy: flexible LTO options. Close more domain deals with financing.

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Switch between accounts
You can now stay logged in to more than one NamePros account in the same browser. Click your avatar, then "Accounts in this browser", to...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back