Results 1 to 10 of 10
  1. #1
    Join Date
    Sep 2003
    Location
    Denver, Colorado
    Posts
    58

    PHP Based navigation. index.php?page=aboutus etc..

    How can I set up links to call a different set of include pages.

    For example: I have my site set up so there is a header.php, body.php, and footer.php.

    I bring them all together with the php includes function inside of another file index.php.

    That works just fine, but it doesn't solve the problem of calling different body pages dynamically.

    I've seen URL's that look like hxxp://somedomain.com/index.php?page=about

    Is this an easy endeavor to take on?

    I'm learning PHP, but this is beyond my scope ATM.

    Thanks in advance.

    Charles
    .:: vento web hosting
    .:: simple hosting, simple solutions, simply reliable
    .:: ventohost.com

  2. #2
    Join Date
    Mar 2004
    Location
    USA
    Posts
    4,342
    I didnt understand what you were trying to do..

    using the variable page is also a good apporach (easier to do).
    Testing 1.. Testing 1..2.. Testing 1..2..3...

  3. #3
    Join Date
    Sep 2003
    Location
    Denver, Colorado
    Posts
    58
    Well, my index.php file has the following.

    Code:
    <?php include ("header.php");
    include ("body.php");
    include ("footer.php");
    ?>
    That's great for the first page. But how would I go about setting up the rest of my pages like aboutus, plans, order to replace the body.php within the code.
    .:: vento web hosting
    .:: simple hosting, simple solutions, simply reliable
    .:: ventohost.com

  4. #4
    Join Date
    Sep 2003
    Location
    Denver, Colorado
    Posts
    58
    What I'm ultimately looking for is a way to set up the links so it looks like this.

    index.php?page=aboutus
    index.php?page=plans
    index.php?page=support

    etc..

    I hope that clears things up.
    .:: vento web hosting
    .:: simple hosting, simple solutions, simply reliable
    .:: ventohost.com

  5. #5
    Join Date
    Sep 2003
    Location
    Portugal
    Posts
    423
    Heyas!

    Try use the "switch" function (http://pt2.php.net/manual/en/control...res.switch.php)

    Example for the address http://mydomain.com/index.php?module=start

    PHP Code:
    <?PHP
    $ModuleToLoad 
    $_Get["module"]

    switch (
    $ModuleToLoad):
    case 
    "start":
       include(
    "modules/start.php");
       break;
    case 
    "contacts":
       include(
    "modules/contacts.php");
       break;
    default:
       include(
    "modules/start.php");
    endswitch;
    ?>
    This code was not tested and I have no clue if it works, at all... But I'd guess it's something like that


    Regards
    Software Project Manager and Architect
    .Net, SQL Server, PHP and MySql

  6. #6
    Join Date
    Jul 2002
    Location
    UK
    Posts
    2,026
    i think you'll have to capitalise it to $_GET

    whatever you do, DON'T do this:

    PHP Code:
    <?php
    include($_GET['page']);
    ?>
    as that will allow someone to include /etc/passwd etc. etc.
    Gone.

  7. #7
    Join Date
    Sep 2003
    Location
    Portugal
    Posts
    423
    Hi again,

    Probably you're right about the $_GET, I don't remember, to be honest

    About security... There are alot of issues to be covered in this kind of "includes"...
    My code, for example, is not secure _AT ALL_. Use it as an example only

    Regards
    Software Project Manager and Architect
    .Net, SQL Server, PHP and MySql

  8. #8
    Join Date
    May 2004
    Location
    San Diego, California
    Posts
    16
    I have already answered this question in another thread is just below this. Please take a look, it has worked for the other member that asked on how to do this.

    http://www.webhostingtalk.com/showth...hreadid=272220

  9. #9
    Join Date
    Sep 2003
    Location
    Denver, Colorado
    Posts
    58
    Originally posted by RyanCurrie
    I have already answered this question in another thread is just below this. Please take a look, it has worked for the other member that asked on how to do this.

    http://www.webhostingtalk.com/showth...hreadid=272220
    Thanks for all the help guys. It works like a charm.
    .:: vento web hosting
    .:: simple hosting, simple solutions, simply reliable
    .:: ventohost.com

  10. #10
    Join Date
    May 2004
    Location
    San Diego, California
    Posts
    16
    Originally posted by ventohost
    Thanks for all the help guys. It works like a charm.
    Glad I can be of assistance and that it is working for you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •