Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: Page names.

  1. #1
    Regular Coder Ranger56's Avatar
    Join Date
    Mar 2005
    Location
    Kent, WA.
    Posts
    783
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Page names.

    How does the whole

    "www.site.com/pages.php?page=blahblah.php"

    Work instead of

    "www.site./blahblah.php"
    ?

  • #2
    Regular Coder
    Join Date
    Aug 2004
    Location
    The US of A
    Posts
    767
    Thanks
    1
    Thanked 0 Times in 0 Posts
    By including the file.

    Here's a quick function I whipped up that should work.

    PHP Code:
    <?php

    function loadPage($name$pages)
        {
        if(isset(
    $name) && isset($pages) && is_array($pages))
            {
            if(isset(
    $pages[$name]))
                {
                require_once 
    $pages[$key];
                return 
    true;
                }
            }
        return 
    false;
        }
        
    ?>
    You would use it like this:

    PHP Code:
    //URL: www.example.net/?page=news
    $pages = array('news' => 'index.php''about' => 'about.php'); //etc
    if(isset($_GET['page']))
        {
        if(!(
    loadPage($_GET['page'], $pages) || $pages[$_GET['page']] === substr($_SERVER['PHP_SELF'], 1)))
            {
            echo 
    'Error';
            }
        } 
    Last edited by Kurashu; 07-08-2005 at 07:04 AM.

  • #3
    Regular Coder Ranger56's Avatar
    Join Date
    Mar 2005
    Location
    Kent, WA.
    Posts
    783
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hmm...I'll try to figure that out...


  •  

    Posting Permissions

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