smerny Posted May 31, 2009 Share Posted May 31, 2009 I wanted to use $_SERVER['REMOTE_ADDR'] in a page that is included in another page.... and it just gives me the IP of the webhost... how can I get around that without having to add to every page that includes this one? Link to comment Share on other sites More sharing options...
jlhaslip Posted May 31, 2009 Share Posted May 31, 2009 http://php.net/manual/en/reserved.variables.server.php 'HTTP_HOST' Contents of the Host: header from the current request, if there is one. 'HTTP_REFERER' The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted. Link to comment Share on other sites More sharing options...
smerny Posted May 31, 2009 Author Share Posted May 31, 2009 'REMOTE_ADDR' The IP address from which the user is viewing the current page.That is what I want by it's description Link to comment Share on other sites More sharing options...
justsomeguy Posted June 1, 2009 Share Posted June 1, 2009 How are you including the file? Are you using HTTP to include it? If so, then what you're describing is the correct behavior. Link to comment Share on other sites More sharing options...
smerny Posted June 2, 2009 Author Share Posted June 2, 2009 I had the same problem with session variables.... how can I do a file include if say i want /folder1/file1.php to include /folder2/file2.php and be able to use session variables or $_SERVER['REMOTE_ADDR']? Link to comment Share on other sites More sharing options...
justsomeguy Posted June 2, 2009 Share Posted June 2, 2009 Just don't include files using HTTP. If all the files are on the same server, use the regular file path to include them instead of HTTP, that's the normal way to include a file anyway. You're sort of breaking file includes if you use HTTP to include them. You should only use HTTP if you're trying to include a file on another server, and even then another way might be better. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.