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
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.  :)
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.