1. Computing

Detect a User's IP Address

How to detect a user's IP address using PHP code

By

An IP address can tell you a lot about a user, such as the general area from which they are visiting your site. This can help you specialize the site's content for your users, or redirect them based on location. You can also use a person's IP address as a security measure to make sure it is actually them logging into their account. You could also use it to check your own IP address to know if a proxy server is working.

 <?php 
 $ip=$_SERVER['REMOTE_ADDR'];
 echo "Your IP Address is $ip"; 
 ?> 

Have something to add? A bit of code? A suggestion of how to use it? View Reader Responses!

Related Video
Link a Website to an Email Address in HTML
  1. About.com
  2. Computing
  3. PHP / MySQL
  4. Learn PHP
  5. How to Detect a User's IP Address Using PHP Code

©2014 About.com. All rights reserved.