RSS

How to Detect IP Address Using PHP

02 Jul

pada PHP ternyata juga ada fungsi yang dapat digunakan untuk mendeteksi IP addres pengunjung

<?php
$ip = $_SERVER['REMOTE_ADDR'];
$browser = $_SERVER['HTTP_USER_AGENT'];
$refer = $_SERVER['HTTP_REFERER'];

echo "ip address = $ip, browser = $browser, referrer = $referrer";
?>

Tapi klo dicoba pada localhost anda pasti hasilnya “ip address = 127.0.0.1, browser = Mozilla/5.0 (Windows NT 6.1) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.77 Safari/534.24 ChromePlus/1.6.2.0, referrer =”

Apapun IP Address anda hasilnya pasti 127.0.0.1
Kenapa?karena itu adalah IP Address untuk localhost, jadi itu yang dipakai, namun jika code PHP tersebut kita pasang pada web hosting tentu hasilnya sesuai IP Address internet kita

Regard,
~andrew90ongi~

 
Leave a comment

Posted by on 2 July 2011 in Software & Development, Website

 

Tags: , , , ,

Monggo share dimari :D

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: