|
|
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.107.191.95
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 |
| |
| | John | 15-06-2009 |
|---|
| I need a script similar to that of the one at tracemyip.com | | anto | 17-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 | | Spirit | 20-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.
| | Myles | 13-07-2009 |
|---|
To John - Thanks for that info, now go and make it.
Anto, type ipconfig in msdos or as is probably more apt.....winipcfg in START then RUN. | | ajay joshi | 19-09-2009 |
|---|
| thanx.. can you show how to get the full details for ip tracing/ip trapping | | CanadaWest | 21-09-2009 |
|---|
You say,
"recording the geographical location of the visitor can be done this way"
How can I get the user's geographical location to redirect the user to the correct info for their region? | | smo | 21-09-2009 |
|---|
| Once IP address is known then the location can be collected by using available geo location tables. These tables are available at cost and can be updated regularly. | | gizmo | 28-11-2009 |
|---|
| can you show how to get the full details for the network addressed | | santosh | 30-12-2009 |
|---|
| how to run the above code?... | | Pham Nguyen | 01-01-2010 |
|---|
| why do i use the code $ip=@$REMOTE_ADDR; on localhost. $ip=127.0.0.1. Please lest me know how about on the host server? | | Krishnat | 31-01-2010 |
|---|
| i want to design cyberoam through php..so please tell me some guideline |
|
|
|
|
|
|