The POST/GET methods do not work as they do in localhost.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Dodo
Forum Newbie
Posts: 3
Joined: Sun Jun 08, 2003 7:32 pm

The POST/GET methods do not work as they do in localhost.

Post by Dodo »

I am just starting learning to create a homepage and I fall in love with PHP at the first glance. I have written some simple PHP scripts and tried them in localhost. Everything seems to be perfect. But they started frustating me since I put them in the real internet. The POST/GET methods do not work as they do in localhost.

The following experiment for example return "is set" in localhost but "is not set" when uploaded.

pageone.php
<?php
$page = '1';
?>
<a href="pagetwo.php?page=<?php echo $page; ?>" >Test</a>

pagetwo.php
<?php
If (!isset($_REQUEST["page"])){
echo "Variable 'page' is not set.";
}else{
echo "Variable 'page' is set.";
}
?>

register_globals in php.ini is already turned OFF.
Using $_GET["page"] also makes no difference.
I can see the variable in URL (.../pagetwo.php?page=1).

I've been surfing everywhere to see what is going on. Can anybody help me to understand why this is happening.
:(
User avatar
Stoker
Forum Regular
Posts: 782
Joined: Thu Jan 23, 2003 9:45 pm
Location: SWNY
Contact:

Post by Stoker »

what version of PHP?
what does
var_dump($HTTP_GET_VARS);
give?
Dodo
Forum Newbie
Posts: 3
Joined: Sun Jun 08, 2003 7:32 pm

Post by Dodo »

PHP version 4.2.2 in localhost. Version 4.0.6 in the internet server.
var_dump?(I don't really understand with this) but when I added var_dump($HTTP_GET_VARS); to the script it gave us something like this "array(1) { ["page"]=> string(1) "1" }"
SBukoski
Forum Contributor
Posts: 128
Joined: Wed May 21, 2003 10:39 pm
Location: Worcester, MA

Post by SBukoski »

The shorthanded variables (eg $_GET, $_POST, $_COOKIE) were introduced in PHP 4.1.0. You have a later version locally but an older one on your Server. The older version doesn't recgonize $_GET. Instead, use $HTTP_GET_VARS to solve the problem.
Dodo
Forum Newbie
Posts: 3
Joined: Sun Jun 08, 2003 7:32 pm

Post by Dodo »

I've tested using $HTTP_GET_VARS and it works as expected. That makes me happy.

Thanks. I really appreciate your help.
Post Reply