Re: [PHP] Verry strange GET behaviour
On the topic of passing args, can someone please explain to me why I'm unable to use $_GET or $_POST if my php script is run as a .cgi? Basically, I have a simple html input form that has: form name=testform action=test.cgi method=GET input type=text name=textbox input type=submit value=Submit /form and a simple php script in a file called test.cgi which looks like: #!/usr/local/bin/php ?php print $_GET['testbox']; ? Now, if I rename this script to test.php, everything works fine, but not while run as a cgi. I have no such problems when implementing the exact same code using Perl, so I'm thinking that php requires a different method of obtaining args when run as a cgi. If anyone can tell me the method, I would greatly appreciate it. Thanks, John --- Chris Shiflett [EMAIL PROTECTED] wrote: --- Ben Edwards [EMAIL PROTECTED] wrote: Been having a problem accessing a variable that is passed on a URL. This question is asked several times a week. You have register_globals disabled, and if you are asking this question, you need to leave register_globals disabled. Use $_GET['_section'] to access your variable. Hope that helps. Chris = My Blog http://shiflett.org/ HTTP Developer's Handbook http://httphandbook.org/ RAMP Training Courses http://www.nyphp.org/ramp -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Verry strange GET behaviour
--- Chris Shiflett [EMAIL PROTECTED] wrote: --- John Wilcox [EMAIL PROTECTED] wrote: On the topic of passing args, can someone please explain to me why I'm unable to use $_GET or $_POST if my php script is run as a .cgi? What you may want to do is to have the Web server interpret .cgi files as PHP, assuming all your CGIs are PHP scripts. Then you can leave out your #! line at the top also. The reason why I'm having my php run as a .cgi in the first place, is because I want the script to inherit the user/group of the virtual host that it's running under (using suEXEC), and this is not possible when using a php script interpreted through the web server. It must be run as a .cgi, since .cgi's will inherit the user/group. This is no problem in Perl, since it provides a way to pass variables from one .cgi to another (using my $query = new CGI; param('testbox');). But I can't figure out how to do this in PHP, since using $_GET['testbox']; always produces Undefined index: testbox in test.cgi on line 8.. Thanks, John P.S. If anyone has any other ideas of how to get a PHP script to run as a specific user/group under a Virtual Host, I'm all ears.. All I need is for the script to be able to mkdir as a specific user/group, but this is proving to be more than a small challenge! __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Passing POST args to PHP when run as a CGI (was Re: [PHP] $_ENV not working for me with PHP 4.2.0)
--- Curt Zirzow [EMAIL PROTECTED] 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] $_ENV not working for me with PHP 4.2.0
I've been trying to make a simple script which just outputs the username that the script is currently executing under (in order to test that suexec is working properly). I've tried using the following line: ?php print $_ENV['USER']; ? and it fails to produce any output and returns the following error in my log file: [Sun Oct 5 14:02:35 2003] [error] PHP Notice: Undefined index: USER in /home/test/test.php on line 1 Now, I've tried the same command on another server running PHP 4.2.0 and it correctly outputs the username as expected. Both these machines are running Debian Linux. Now I figure it must be some configuration setting that is messing this up somehow, but I have no idea where to look. I've checked out the documentation and it states that PHP versions later than 4.2.0 use the $_ENV global variable to access environment variables, so it seems like I'm using it correctly. Anyways, if anyone has any suggestions, please let me know! Thanks in advance, John Wilcox __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $_ENV not working for me with PHP 4.2.0
Hi Tom, when I put echo `printenv`; into a script, I see in big bold letters: USER=john so this environment variable seems to be available.. getenv('USER'); works fine, so I guess I'll just use that instead.. No idea why $_ENV['USER']; doesn't work though. Thanks for the suggestion, John --- Tom Rogers [EMAIL PROTECTED] wrote: Hi, Monday, October 6, 2003, 4:43:20 AM, you wrote: JW I've been trying to make a simple script which just JW outputs the username that the script is currently JW executing under (in order to test that suexec is JW working properly). I've tried using the following JW line: JW ?php print $_ENV['USER']; ? JW and it fails to produce any output and returns the JW following error in my log file: [Sun Oct 5 14:02:35 JW 2003] [error] PHP Notice: Undefined index: USER in JW /home/test/test.php on line 1 JW Now, I've tried the same command on another server JW running PHP 4.2.0 and it correctly outputs the JW username as expected. Both these machines are running JW Debian Linux. JW Now I figure it must be some configuration setting JW that is messing this up somehow, but I have no idea JW where to look. I've checked out the documentation and JW it states that PHP versions later than 4.2.0 use the JW $_ENV global variable to access environment variables, JW so it seems like I'm using it correctly. Anyways, if JW anyone has any suggestions, please let me know! JW Thanks in advance, JW John Wilcox JW __ JW Do you Yahoo!? JW The New Yahoo! Shopping - with improved product search JW http://shopping.yahoo.com Do this to see what is available in your enviroment, it would seem that USER is not being set by the system or is called something else. echo `printenv`; (use backticks) -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php