PHP globals was Re: CFM vs ASP

by Kathy Wheeler <kathyw(at)home.albury.net.au>

 Date:  Wed, 15 May 2002 17:24:21 +1000
 To:  "Mike Taylor" <lonewolf(at)one.net>
 Cc:  <hwg-techniques(at)hwg.org>
 References:  nuvox kathydell oemcomputer
  todo: View Thread, Original
On Wednesday 15 May 2002 11:09, Mike Taylor wrote:
> The environment variables work if I use the same CGI program as an SSI in a
> non-PHP page. 
[snip]
> Wacky.

Not at all. PHP has a different and separate security model. Yes, they (the 
cgi and your PHP script) may be looking for the same environment variable, 
but they both have their own internal method of referring to it. As long as 
PHP is configured with track_vars on and register_globals off, you will need 
to query the appropriate $HTTP_SERVER_VARS["name"] (or $HTTP_POST_VARS , 
$HTTP_GET_VARS , etc) in your PHP script to get the variable into it.

eg 
<?php
if($HTTP_SERVER_VARS["REMOTE_ADDR"]) $ip = $HTTP_SERVER_VARS["REMOTE_ADDR"];
?>

will put the IP address into the $ip variable. You can refer to it as 
$HTTP_SERVER_VARS["REMOTE_ADDR"]
but that becomes a pain if you need it more than once!

Cheers,
KathyW.

HWG hwg-techniques mailing list archives, maintained by Webmasters @ IWA