You are using a browser which is not compatible with CSS (for more information, see Tara's tutorial).
Because of this, it is possible that our website may not appear
correctly in your browser. We apologise for the inconvenience, and
recommend you upgrade your browser to one which is compatible with CSS.
For more information, please visit our Browser Upgrade page.
This script will output the IP of the visitor. In some cases, $REMOTE_ADDR
needs to be replaced with $HTTP_X_FORWARDED_FOR
. This code can be used in any page which is parsed by PHP (usually with a .php extension).
<?php ########################################################################### # # # Neither http://www.4webhelp.net/ nor its members accept any # # responsibility, either expressed or implied, for any damage caused by # # using this script or the misuse of this script. # # # # # # INSTRUCTIONS # # # # 1) Copy this code to an editor such as Notepad and save it with a # # .php extension. # # 2) FTP this file to a folder on your site in ASCII mode # # 3) Call up this file in your web browser to see your IP # # # ########################################################################### print ('Your IP is: '.$_SERVER['REMOTE_ADDR'].'.'); ?> <p>This script courtesy of <a href="http://www.4webhelp.net/">4WebHelp</a>.</p>
http://strictcoder.blogspot.com/2009/08/different-ways-to-query-for-ip-in-your.html
<?php
//GLOBALS OFF WORK ROUND
if (!ini_get('register_globals')) {
$reg_globals = array($_POST, $_GET, $_FILES, $_ENV, $_SERVER, $_COOKIE);
if (isset($_SESSION)) {
array_unshift($reg_globals, $_SESSION);
}
foreach ($reg_globals as $reg_global) {
extract($reg_global, EXTR_SKIP);
}
}
//FIND THE VISITORS IP
if (getenv("HTTP_CLIENT_IP") && strcasecmp(getenv("HTTP_CLIENT_IP"), "unknown"))
{
$rip = getenv("HTTP_CLIENT_IP");
}
else if (getenv("HTTP_X_FORWARDED_FOR") && strcasecmp(getenv("HTTP_X_FORWARDED_FOR"), "unknown"))
{
$rip = getenv("HTTP_X_FORWARDED_FOR");
}
else if (getenv("REMOTE_ADDR") && strcasecmp(getenv("REMOTE_ADDR"), "unknown"))
{
$rip = getenv("REMOTE_ADDR");
}
else if (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], "unknown"))
{
$rip = $_SERVER['REMOTE_ADDR'];
}
else
{
$rip = "unknown";
}
//DISPLAY THE VISITORS IP
echo "Your IP is $rip";
?>
<?php
//Globals off work round
if (!ini_get('register_globals')) {
$reg_globals = array($_POST, $_GET, $_FILES, $_ENV, $_SERVER, $_COOKIE);
if (isset($_SESSION)) {
array_unshift($reg_globals, $_SESSION);
}
foreach ($reg_globals as $reg_global) {
extract($reg_global, EXTR_SKIP);
}
}
//Find the IP of the visitor
if (getenv("HTTP_CLIENT_IP") && strcasecmp(getenv("HTTP_CLIENT_IP"), "unknown"))
{
$rip = getenv("HTTP_CLIENT_IP");
}
else if (getenv("HTTP_X_FORWARDED_FOR") && strcasecmp(getenv("HTTP_X_FORWARDED_FOR"), "unknown"))
{
$rip = getenv("HTTP_X_FORWARDED_FOR");
}
else if (getenv("REMOTE_ADDR") && strcasecmp(getenv("REMOTE_ADDR"), "unknown"))
{
$rip = getenv("REMOTE_ADDR");
}
else if (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'],
"unknown"))
{
$rip = $_SERVER['REMOTE_ADDR'];
}
else
{
$rip = "unknown";
}
//Display the IP of the Visitor
echo "Your IP is $ip";
?>
<?php
$ip = getenv(REMOTE_ADDR);
print "Your IP Address is ".$ip;
?>
Ex. <title><?php print ($_SERVER['REMOTE_ADDR']); ?></title>
Is there any way to track the IP's?
I'm working on a local machine and know all my users IP's and names. Can I add this to a database so I can see whos using what pages etc?
Is there a application which can help me with?
Thanks
Badger
print ('Your IP is: '.$REMOTE_ADDR.'.');
?>
print ('<font size="X">Your IP is: '.$REMOTE_ADDR.'.</font>');
?>
Add a new comment