Passing POST args to PHP when run as a CGI (was Re: [PHP] $_ENV not working for me with PHP 4.2.0)
| From: | John Wilcox | Date: | Mon, 06 Oct 2003 22:57:42 +0000 |
| Subject: | Passing POST args to PHP when run as a CGI (was Re: [PHP] $_ENV not working for me with PHP 4.2.0) | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-165254@lists.php.net to get a copy of this message | ||
--- Curt Zirzow <php-general@zirzow.dyndns.org> wrote:
> Technically it is 4.1.0 (where did you see the
> 4.2.0?) but anything
> prior to that you should use $HTTP_ENV_VARS
my mistake, you're right, it was 4.1.0.
>
http://php.net/manual/en/language.variables.predefined.php
> http://php.net/manual/en/reserved.variables.php
>
> A diff of your php.ini will tell the story I'll bet
> a diff output
> would be something like:
>
> 306c306
> > variables_order = "GPCS"
> ---
> < variables_order = "EGPCS"
yes, you're correct, my php.ini uses 'variable_order =
"GPCS"'. I tried changing this to "EGPCS", but
$_ENV['USER']; would still not work.
> To get the user that apache is really running as you
> want to do
> something like:
>
> print
whoami;
I've been playing around a bit more, and made a simple
script:
<?php
echo getenv('USER'), "<br />";
print whoami . "<br />";
print $_ENV['USER'];
?>
It produces the following output:
john
nobody
(and an error is produced in the logfile for
$_ENV['USER']: Undefined index: USER)
Now, I'm running this PHP script from within a virtual
host with a certain user/group (test/test - made
possible by using suEXEC), so I can't understand why
"getenv('USER');" is returning "john"..
Anyway, I've been reading up on using suEXEC with PHP
scripts, and it looks like the scripts have to be run
as a .cgi in order to inherit the user/group of the
virtual host.. I've tried changing around one of my
PHP scripts so that it runs as a cgi (basically I just
renamed the file to test.cgi and added
#!/usr/local/bin/php to the beginning of the script).
The only problem is that now my $_POST['TEST'];
doesn't work within the script, so my new problem is
how to figure out passing variables from one script to
another when using PHP as a .cgi. Am I doing
something wrong, or does something need to be changed
in order for PHP to be able to receive these POST
variables?
If anyone has any ideas, please let me know. Thanks
in advance,
John
__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com