Nov 8, 2009

Show Visitors Ip Addresss

free web hosting
Open Discussion > MODERATED AREA > Computers > Programming Languages > PHP Programming

Show Visitors Ip Addresss

cragllo
Want to show the IP of the visitor to your site?
All you have to do is add this code to your page where you want the IP to be shown:
[br]
CODE
<?php[/br]echo "Your IP is $_SERVER["REMOTE_ADDR"]";
?>

Comment/Reply (w/o sign-up)

desimela
o tht was a cool lil script
thx for shairing

Comment/Reply (w/o sign-up)

nancmu
This is one choice!! smile.gif
i usually use this for count my user and show ip. i got user more...

if (getenv(HTTP_CLIENT_IP)) { // check ip from share internet
$ip = getenv(HTTP_CLIENT_IP);
} elseif (getenv(HTTP_X_FORWARDED_FOR)) { // ip is pass from proxy??
$ip = getenv(HTTP_X_FORWARDED_FOR);
} else {
$ip = getenv(REMOTE_ADDR);
}

Comment/Reply (w/o sign-up)

faceofdie
I Use this Code ::
< ?
echo "Your IP is $REMOTE_ADDR";
?>
but It Show Me Last IP and Not Today IP
what is problem >?

Comment/Reply (w/o sign-up)

cragllo
What do you mean Last IP? Go to the page where that code it, and then go into dos and type in ipconfig
it the ip's match, then it is working ok...

if you nitice there is a space between the < and the ?, take taht out, so it should look like <? try that...

Comment/Reply (w/o sign-up)

mrkill47
i tried it and it doesn't work for me either, i get this error:

Notice: Undefined variable: REMOTE_ADDR in c:\program files\easyphp1-7\www\index.php on line 10

Code i used is:

<p><?php echo "Your IP is $REMOTE_ADDR"; ?></p>

the page is located here: http://82.43.57.227/index.php (this is my home pc/server btw, its not always up lol... sorry if its down)

Comment/Reply (w/o sign-up)

cragllo
Are all the features og PHP turned on, on your server?

Comment/Reply (w/o sign-up)

mrkill47
not sure lol, does this help: http://82.43.57.227/uwd/index.php?page=phpinfo

i tried this code instead:

echo "User's IP address: " . $_SERVER["REMOTE_ADDR"];

that seems to have worked...

Comment/Reply (w/o sign-up)

FaLgoR
If global vars are turned on, use $REMOTE_ADDR, else, use $_SERVER["REMOTE_ADDR"]. smile.gif

Comment/Reply (w/o sign-up)

(G)Anonymous

Use

<?
If (getenv(HTTP_CLIENT_IP)) {
$ip = getenv(HTTP_CLIENT_IP);
} elseif (getenv(HTTP_X_FORWARDED_FOR)) {
$ip = getenv(HTTP_X_FORWARDED_FOR);
} else {
$ip = getenv(REMOTE_ADDR);
}
Echo "Your IP is $ip";
?>

 already script for you.

 

-reply by Anonymous
Keywords:

Comment/Reply (w/o sign-up)



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)

Similar Topics

Keywords : show, visitors, ip, addresss

  1. <?php ?> Unique Visitors Script
    Flat file unique visitors script (no sessions) (2)
  2. Visitors Online
    With PHP (no MySQL is needed) (9)
    Another script, which shows the visitors onlineat the moment in your site. This script was not made
    by me, I just think it will be very usefull to u. CODE $timeout = 15; // change it. It is the
    timer which will delete the member of  online list (in minutes) if (!$datei) $datei =
    dirname(__FILE__)."/online.txt"; $time = @time(); $ip = $REMOTE_ADDR; $string = "$ip|$time\n"; $a =
    fopen("online.txt", "a+"); fputs($a, $string); fclose($a); $timeout = time()-(60*$timeout); $all =
    ""; $i = 0; $datei = file("online.txt"); for ($num = 0; $num $pieces = explode("|",$datei....
  3. Visitors Counter
    With PHP (no MySQL needed!) (4)
    Well, here we will make an hit counterusing php and an *.txt file. This script is so simple, but
    very usefull. First, le'ts make an file called counter.php, with the following codes inside:
    CODE $file = 'counter.txt'; // this is the file where the number of visitors will be
    written $fopen = fopen("$file", "r"); // open the text file $count = fread($fopen, 1024); // read
    the text file fclose($fp); // close the text file $count = $count + 1; // add one more hit echo
    "$count"; // print the number $fopen = fopen("counter.txt", "w"); // open the file again....
  4. Php Hit Counter
    record your visitors... (3)
    All you do is copy this code into the page you want to display it on. CODE $counterfile =
    "counter.txt"; $counter = file("$counterfile"); $c = $counter ; if (strlen($c) == 0) {$c=0;}
    $c=$c+1; $a = fopen("$counterfile", "w"); fwrite($a, $counter = ""); fputs($a, $c); fclose($a); echo
    ("$c"); ?> Make a file called 'counter.txt' in the same directory as the page the code is
    on. Remember to CHMOD your txt file to 666. (change the permissions to 666)....

    1. Looking for show, visitors, ip, addresss

Searching Video's for show, visitors, ip, addresss
See Also,
advertisement


Show Visitors Ip Addresss

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com