Results 1 to 3 of 3

Thread: PHP linkin (GET method)

  1. #1
    Join Date
    Jun 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default PHP linkin (GET method)

    What i want is that links to an other php page not are of index.php to info.php but of index.php to index.php?page=info.php

    The fellowing script is doing that: (index2.php is the main page)

    <?php
    if($_GET['page']=='info')
    {
    include('info.php');
    }
    else
    {
    include('index2.php');
    }
    ?>

    But when i add a second page on the same way as info.php he does not only display the second page but also index2.php.

    How can i fix this. I have allready tried a lot of things but i am not very good whit php scripts!

  2. #2
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    For every other condition (other than the first if and the last "else" statement), you need to have "elseif".

    Code:
    <?php
    if($_GET['page']=='info')
    {
    include('info.php');
    }
    
    elseif ($_GET['page'] == 'other') {
    include('other.php');
    }
    
    else
    {
    include('index2.php');
    }
    ?>
    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  3. #3
    Join Date
    Jun 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Yes it is working perfect

    Thank you very much!!

Bookmarks

Posting Permissions

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