SQL PHP HTML ASP JavaScript articles and free scripts to download If you are facing any problem in viewing this page, please tell us
 

PHP script to Find out IP address

We can get the IP address of any visitor by using PHP. Finding the IP address is very important requirement for many scripts where we store the members or visitors details. For security reason we can store IP address of our visitors who are doing any purchases or recording the geographical location of the visitor can be done this way. Some time based on the IP address we can redirect the browser to different areas of the site. There are many applications using this and here is the PHP code to know the IP address of any visitor to the site.

$ip=@$REMOTE_ADDR;
echo "<b>IP Address= $ip</b>";


The above code will display this IP address= 38.103.63.59

IP address if the register_global is off
If at php.ini if register_global is set to Off then we have to change the script a bit to get the address. Here it is

$ip=$_SERVER['REMOTE_ADDR'];

You can see the modification done to signup & login script if global variable is OFF
We can convert the dot formatted IP address to number by using ip2long function and store in MySQL database.

Same way you can find out the referrer to your site by using PHP.


How to get IP address in ASP ?

Read article on visitor tracking
John15-06-2009
I need a script similar to that of the one at tracemyip.com
anto17-06-2009
nice.. can you show how to get the full details for the network addressed including the gateway and sub-net mask? thank you
Spirit20-06-2009
You cannot find out somone's subnet mask, or gateway externally. Both are part of their internal network, all of which shares the same external IP.
Post Comment This is for short comments only. Use the forum for more discussions.
Name
Email( not to be displayed)Privacy Policy
1+2=This is to prevent automatic submission by spammers. Please enter the result of the sum as asked
 

Subscribe
Submit your email address and receive article and product notifications. Your email is safe with us.

Scripts
PHP
JavaScript
PHP Tutorials
IP & Referrer
PHP Monthly Planner
PHP Introduction
Loops & structure
Array
Date & Time
Functions
Form Handling
File Handling
Math Functions
String Functions
GD Functions
Comment Posting
Content Management
PHP & Ajax
Popular Tutorials
Drop down list
File Upload
Signup script
Member Login
Line Graph
PHP MySQL Paging
PHP Calendar
Subscribe
Submit your email address and receive article and product notifications. Your email is safe with us.