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
  1. #1
    New Coder
    Join Date
    Sep 2002
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Linking question:

    I've forgotten how to make links that use a page and then include information. Ok, so that wasn't clear at all, I'll try to explain:
    Say I have a a page (index.php) and I want to keep the index layout on all my pages, so I have a link set up that will display the content wherever I want it on the page. When the link is placed, the adress will look like "index.php?inc=content". Once it hits that link, the layout will stay the same, but the content will change. I've done this before a long time ago, and since then I've deleted my examples. All I remember is that it involved this piece of code:

    <?php
    include($_GET['content'] . '.php');
    ?>



    I'm not sure if to some people it seems really obvious, but I'm not strong in php, and this may be all of the code I need, but I don't know how to use it properly.
    Any help would be nice.
    ~Mike

  • #2
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    Close

    PHP Code:
    <?
    include($_GET['inc'].'.php');
    ?>
    It's the value of inc you want, not content

  • #3
    Regular Coder
    Join Date
    Sep 2002
    Location
    British Columbia
    Posts
    235
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I would advise against doing that for security reasons.

    At least validate the incoming data

    PHP Code:
    <?

    if (in_array($_GET['inc'], array('array''of''valid''page''filenames'))) {
        include(
    $_GET['inc'].'.php');
    }

    ?>


  •  

    Posting Permissions

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