Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.