Jump to content

Variable passing via URL :: using in case()


RavynX

Recommended Posts

Hey all, I've been using a switch statement in my dad's webpage in order to decide what page to display or what photos to display.  It's been working for some time now, but I checked his site recently and it passes all of the cases, no matter what that variable is, and goes to the default state.


Example URL: /index.php?page=pricing

[code]
<?php
switch ($page) {
case "pricing":
include('pricing.inc') ;
break;


default:
include('main.inc');
break;
};
?>
[/code]

But instead of loading the pricing.inc file it will load the main.inc.  If I add a case for "main" and make the default case include pricing, the page will pop up as the pricing page.


Also, I work on my /localhost/ using phpTriad, and the website works perfectly.  My /localhost/ uses PHP 4.1.1 while our webhost uses 4.4.1.  Was variable passing affected between the two versions?
Link to comment
https://forums.phpfreaks.com/topic/26171-variable-passing-via-url-using-in-case/
Share on other sites

[quote author=ToonMariner link=topic=113849.msg462958#msg462958 date=1162670258]
looks like  register_globals....

make sure that you have $page = $_GET['page'] somewhere before that switch.
[/quote]

Very nice, thanks for your help.  That fixed it.  :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.