PHP not reading pass variable in url

I am having problem with a code a file called config.php is included in the top of all the pages and this is the read code from it. but it is not reading It might be a setting in php.ini i need to change but not sure.

if (!empty($HTTP_ENV_VARS)) while(list($name, $value) = each($HTTP_ENV_VARS)) $$name = $value;
if (!empty($HTTP_GET_VARS)) while(list($name, $value) = each($HTTP_GET_VARS)) $$name = $value;
if (!empty($HTTP_POST_VARS)) while(list($name, $value) = each($HTTP_POST_VARS)) $$name = $value;
if (!empty($HTTP_COOKIE_VARS)) while(list($name, $value) = each($HTTP_COOKIE_VARS)) $$name = $value;
if (!empty($HTTP_SERVER_VARS)) while(list($name, $value) = each($HTTP_SERVER_VARS)) $$name = $value;

I don’t understand the question, but I have two things to say:

  • There are better ways to do this.
  • Doing this is a bad idea in the first place.

The register_globals setting was defaulted to off many years ago for security reasons. The setting itself is not insecure, the entire idea is. By hacking your way around like this, you’re not helping yourself.

I am not sure this should be part of the same thread, but I think my problem also has to so with the register_globals setting.

I can’t get this snippet to work. I would like to capture the referring URL
and parse the string.

Thanks.

<?php $refer_array = split(".",$_SERVER['HTTP_HOST']); foreach ( $refer_array as $item ) print "$item
"; ?>

What results do you get? Errors? Output? Anything?
Also are you sure that you will end up with an array? If you echo out $_SERVER[‘HTTP_HOST’] by itself will you get what you expect? What is it that you do get?

Ya its not my choice… this was a pre-written script…

This is part of a config.php file that is included on the top of all of the files… is there a way to rewrite this cause this part of the script isn’t reading the URL

I do not get anything at all, no output. Is there a different way to get the previous URL visited? It seems the $_SERVER[‘HTTP_HOST’ portion of this does not work.

Ultimately my site is linked to by several source sites. I need to keep track of where visitors are coming from.
Thanks.

If you are trying to keep track of sites that are LINKED to your site (as users come from those sites), then you probably want the HTTP_REFERER and NOT HTTP_HOST. The referer is WHERE the link is from that brought you to that page where the host is the site that is displaying the page.

Also as a check to help me when I am debugging, I often want to know what is being sent and how. So I have an Include file like the following:
[php]

<?php echo '

$_POST
'; while(list($Index, $content)= each($_POST)) echo $Index." - ".$content."
"; echo '

$_SERVER
'; while(list($Index, $content)= each($_SERVER)) echo $Index." - ".$content."
"; echo '

$_REQUEST
'; while(list($Index, $content)= each($_REQUEST)) echo $Index." - ".$content."
"; echo '

$_ENV
'; while(list($Index, $content)= each($_ENV)) echo $Index." - ".$content."
"; echo '

$_SESSION
'; while(list($Index, $content)= each($_SESSION)) echo $Index." - ".$content."
"; echo '

$_FILES
'; while(list($Index, $content)= each($_FILES[userfile])) echo $Index." - ".$content."
"; ?>

[/php]

I will include the file in an appropriate portion of code and it will echo out the contents of the various arrays so that I know what’s in them, for a given page.

It may give errors, such as the $_FILES section, if there is no file uploaded, but they can (generally) be safely ignored.

If you get NOTHING… then there is a whole other issue going on. (Perhaps configuration?)

Ok Peg110

I used your debugging tech and it worked… then i tried combining your code with the config.php code and now it works great.

thnx for your help.

Sponsor our Newsletter | Privacy Policy | Terms of Service