Jump to content

Recommended Posts


Hello -

If I run the following PHP the output is OK:

<?php
$remote_addr = $_SERVER['REMOTE_ADDR'];
$http_user_agent = $_SERVER['HTTP_USER_AGENT'];
echo "REMOTE_ADDR: $remote_addr";
echo "HTTP_USER_AGENT: $http_user_agent";
print_r($GLOBALS);
?>

However, if I run this as an "include", only the IP address of the UNIX server hosting Apache is output.

Also, I seem to have lost the following:

$_SERVER['HTTP_REFERER'];

This was outputting correctly but now outputs nothing.

Why is this?

Regards,

Neil.

It is included as follows:

<?php include("http://www.servername.com/includes/myinclude.php"); ?>

This output what it should have done.

I also tried:

<?php include("/includes/myinclude.php"); ?>

This returned nothing.

But what is also wierd is that I used to get a value for $_SERVER['HTTP_REFERER'] but I do not any longer.



Any clues?

Cheers,

Neil.
If the file is local, you do not want to use the full URL. That gets rid of your first attempt.

Your second attempt:
[code]<?php include("/includes/myinclude.php"); ?>[/code]
is telling PHP to look for the file in the directory "includes" directly under the root directory of your machine. This is probably not the correct place to look.

If you do
[code]<?php include("includes/myinclude.php"); ?>[/code]
instead, it will tell PHP to look for the "includes" in the same directory as the script is located. This is probably what you want.

Ken

Hi -

I've tried different permutations of your suggestion with the following code:

<?php
$remote_addr = $_SERVER['REMOTE_ADDR'];
$http_referer = $_SERVER['HTTP_REFERER'];
$http_user_agent = $_SERVER['HTTP_USER_AGENT'];
echo "REMOTE_ADDR: $remote_addr";
echo "HTTP_REFERER: $http_referer";
echo "HTTP_USER_AGENT: $http_user_agent";
print_r($GLOBALS);
echo "<br><br><br><br><br>";
echo "HTTP_SERVER_VARS";
echo "$HTTP_SERVER_VARS";
echo "<br><br><br><br><br>";
?>

1.) <?php include("http://www.mysite.com/myinclude.php"); ?>
and
2.) <?php include("myinclude.php"); ?>
and
3.) <?php include("/path/from/root/to/myinclude.php"); ?>

The first instance of HTTP_REFERER is OK. In the include only the 1.) (full URL) echoes out anything at all. 2.) and 3.) provide no output. However, 1.) does not list the REMOTE_ADDR correctly and does not output anything for the HTTP_REFERER. Instead of it being the correc referrer IP address, it is the IP address of the machine serving www.mysite.com.

Any ideas?

Regards,

Neil.


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.