Wednesday 5 March 2014

How to get IP address of user in PHP

Some time you guys may think, How, websites know about your location or google analytic distinguish different user on internet Or locate your location . this all happen due to your IP address .
IP stands for Internet Protocol .

What is IP address?

Simply, It is an Unique number assigned to each device( like PC,printer,router etc. ) in a computer network.
It is just like address or identity in network .

To get the IP address of a visitor to your website .

Run a PHP program on your web server .

PHP Program :




  
 <?php  
 // www.beginer2cs.blogspot.com 
 $ip_address = $_SERVER['REMOTE_ADDR'];  //get ip address (inbuilt function in php )
 echo "your ip address is ".$ip_address;   //print ip
 ?>  

Since I run this code at localhost that is  why my localhost ip  was printed 


But if this code is implemented at any page of any website and you gonna open that page your IP address is fetch . and you are no more anonymous . that is why when you open any website using proxy sites  IP address of proxy site is send to website owner not yours

Best example is open  whatismyip  and it will show you your IP address now again open using a proxy site you can see, It shows IP address , It is not your's .basically it is ip address of proxy server .

Thanks have a NIce Day !!!
Related Post :  Test your Programming Skill : P-1 

2 comments:

  1. Exquisite study and a well thought out article. Well done.


    Review my website; eliquid

    ReplyDelete
  2. Howdy! I just want to offer you a big thumbs up for your excellent info you have got here on this post.

    I'll be coming back to your website for more soon.

    my site :: Christian Louboutin Toronto

    ReplyDelete

THANKS FOR UR GREAT COMMENT

Blogger Widgets