Gossamer Forum
Home : General : Internet Technologies :

$_POST won't work within a subdirectory

Quote Reply
$_POST won't work within a subdirectory
OK, it is time for my next dumb question.

I have a site written in PHP which works just fine. I have a copy of it in a subdirectory (/development). In that subdirectory, $_POST variables are not populated. Is there a configuration section where I have to tell apache to allow PHP to run in any directory? I wouldn't think so, but I have been wrong many times before!

Thanks for any help.
Quote Reply
Re: [Lee] $_POST won't work within a subdirectory In reply to
Does PHP run at any time in that directory?

Have you tried making $_POST a global? Your host may have register_globals turned off.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] $_POST won't work within a subdirectory In reply to
No Andy, but thanks for the suggestion. We host the web site locally so I have full control of the config files and register_globals is on. Arggghhhhh. I want perl back! :)
Quote Reply
Re: [Lee] $_POST won't work within a subdirectory In reply to
You tried $POST ?

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] $_POST won't work within a subdirectory In reply to
$_POST works fine in the root directory.
Quote Reply
Re: [Lee] $_POST won't work within a subdirectory In reply to
Very odd. As far as I know, you shouldn't have to set any options in the php.ini/php.conf file... if it works in root, it should work in a sub directory Unsure

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] $_POST won't work within a subdirectory In reply to
That's what I thought ... thanks.
Quote Reply
Re: [Lee] $_POST won't work within a subdirectory In reply to
Actually, you can change many config settings on a per directory or per script basis. To change them for a directory, you'd use an .htaccess file with something like:

php_value register_globals 1

or in an individual script you'd use:

ini_set('display_errors', 0);

Those are just stupid examples, you can get much more detailed info at:

http://www.php.net/ini_set

That said, the availability of $_POST itself shouldn't have anything to do with register_globals. The whole point of register_globals is that it extracts the variables within $_POST (and $_GET, etc.) and makes them available.

Two suggestions:

1) What happens if you try $HTTP_POST_VARS instead?
2) Can you post the code that's having the problem?

Fractured Atlas :: Liberate the Artist
Services: Healthcare, Fiscal Sponsorship, Marketing, Education, The Emerging Artists Fund
Quote Reply
Re: [hennagaijin] $_POST won't work within a subdirectory In reply to
OK, $_POST still doesn't work, but I have a question:

The way my script works is index.php is originally called and then does a search for all documents in the same directory which end with .lee and includes them. Does php have to be told (php.ini?) which extensions are legitimate php files? In other words, is my $_POST not working because of the extension?

It's hard to post the code to show since there are several linking libraries, etc., but except for the $_POST issue, everything works fine.
Quote Reply
Re: [Lee] $_POST won't work within a subdirectory In reply to
If you include or require a file in a PHP script, any PHP code in the file will be executed regardless of the file's extension. So that probably isn't your problem.

For security reasons, it's probably better to name those files file.lee.php instead of file.lee, however. With the .lee extension, anyone could point their browser to the page and read your php code, which could illuminate vulnerabilities.

Fractured Atlas :: Liberate the Artist
Services: Healthcare, Fiscal Sponsorship, Marketing, Education, The Emerging Artists Fund
Quote Reply
Re: [hennagaijin] $_POST won't work within a subdirectory In reply to
After fighting with this issue for a week, I FINALLY got the problem resolved and thought I would post the 'fix' just in case anyone else ever encounters this problem.

The URL I used in my "<FORM action=" was http://mysite.com/development?5 which called 'page 5' of the site. From my perl days this works great ... apparently PHP requires that you place a slash after the directory: hence: http://mysite.com/development/?5. After doing that, all is well.

Thanks again for all your insight though. This board rocks.