toasty525 Posted August 20, 2009 Share Posted August 20, 2009 Hi, i am trying to log the users ip when they visit one of my sites the setup is as follows: i have one page on a site 1 that has the code: <?PHP $ip=$_SERVER['REMOTE_ADDR']; echo $ip; ?> and another page on site 2 that has the code: <?PHP include('http://site1.com/gettest.php'); ?> When a user visits site 2 i want site 1 to log there IP address but instead it only logs the IP address of the host for site 2. Any help would be great thanks Link to comment https://forums.phpfreaks.com/topic/171169-loging-remote-ip-not-working-as-i-require-it-to/ Share on other sites More sharing options...
ignace Posted August 20, 2009 Share Posted August 20, 2009 but instead it only logs the IP address of the host for site 2. You get the host address because you are testing it locally. So therefor the ip-address = the host-address. Link to comment https://forums.phpfreaks.com/topic/171169-loging-remote-ip-not-working-as-i-require-it-to/#findComment-902647 Share on other sites More sharing options...
PFMaBiSmAd Posted August 20, 2009 Share Posted August 20, 2009 You are including a file using a URL. When you do that, php makes a HTTP request to that URL to get the output from that file, just as though your server browsed to that URL. USE A FREAKING LOCAL FILE SYSTEM PATH to the file you are including if you expect the code and data in that file to be available in the main file that is including it and for it to use the values from the HTTP request a browser just made to your page instead of the HTTP request that your page just made to different URL. Link to comment https://forums.phpfreaks.com/topic/171169-loging-remote-ip-not-working-as-i-require-it-to/#findComment-902731 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.