Myf
Myf

Reputation: 21

$_GET and $_POST not working

I am a beginner in php and am trying some very simple tests to get started.

I seem to be unable to get any values from $_GET.

This test.php

#!/usr/bin/php

<html>
<body><h1>GET test</h1><p>
<?php
    print_r($_GET);
?>
</p></body></html>

produces the following when called with http://my.url/test.php?aValue=A&bValue=B

<html>
<body><h1>GET test</h1><p>
Array
(
)
</p></body></html>

I do not have write access to /etc/php.ini on the server, but check register_globals and it is off.

I have also tried using $_POST method, but this also doesn't work.

PHP version: PHP 5.1.6

Upvotes: 2

Views: 4897

Answers (1)

nash
nash

Reputation: 2191

The $_GET and $_POST variables are only available if track_vars is turned on.

As of PHP version 4.0.3 that is always automatically enabled.

Can you check your PHP version and also check the value of track_vars in php.ini?

It would also be helpful if you check phpinfo();

<?php
phpinfo();
?>

Check for

  • something called --enable-track-vars, which should be present.

  • _SERVER["argv"], should contain an array if you pass vars via a GET request.

  • also "Loaded Configuration File" should resolve to the file you think it is.

source: PHP: Description of core php.ini directives

Upvotes: 4

Related Questions