rookie question

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
cosinus
Forum Newbie
Posts: 2
Joined: Sun Mar 15, 2009 8:52 pm

rookie question

Post by cosinus »

I have created simple php pages
http://www.authentichomes.us/index.php

and looks like it only shows main page , about_us.php, script just performs this line all the time:

Code: Select all

default : include("about_us.php"); break;
which is inside of this simple script :

Code: Select all

 
        <?php
        // page
                 
                switch($page)
                 {
                   case "services" : include("services.php"); break;
                   case "gallery " : include("gallery.php"); break;
                   case "contact_us" : include("contact_us.php"); break;
                   case "faq" : include("faq.php"); break;
                   default : include("about_us.php"); break;
                 }
        ?>
       
parametr $page seems not to be set but I dont know why,
thanks for any input to this
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: rookie question

Post by requinix »

I don't see where you define $page. If it comes from the URL then you have to tell PHP about it with the $_GET array.

Code: Select all

$page = $_GET["page"];
If someone goes to your site then there won't be a $_GET["page"] yet and PHP will give you a warning about it (which you might not see). You should check that it exists before trying to access it.

Code: Select all

// if it's there, use it, otherwise just use an empty string
$page = (isset($_GET["page"]) ? $_GET["page"] : "");
cosinus
Forum Newbie
Posts: 2
Joined: Sun Mar 15, 2009 8:52 pm

Re: rookie question

Post by cosinus »

Thank you for a quick reply :lol:
Post Reply