Jump to content

loging remote ip not working as i require it to


toasty525

Recommended Posts

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 :D

 

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.