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 11 of 11

Thread: $get

  1. #1
    New to the CF scene
    Join Date
    May 2009
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    $get

    Hey

    I am creating a website and using /index.php?page= to display my content. I have come to a stage where I need to show multiple things for one page but on seperate pages. For example /index.php?page=shows?dj=autodj then i would need another one for /index.php?page=shows?dj=djjohn for example. How can I go about doing this?

    Here is my code:
    PHP Code:
    <?php
    if(file_exists($_GET['page'].".php"))
    include (
    $_GET['page'].".php");
    else include(
    "main.php"); 
    ?>
    Also can you tell me why this more secure one won't work?

    PHP Code:
    <?php
    if(isset($_GET['page'])) {
    if(
    file_exists('pages/'.$_GET['page'].'.php')) {
    include(
    'pages/'.$_GET['page'].'.php');
    }
    else {
    echo(
    'Page not found.');
    exit;
    }
    else {
    include(
    'pages/main.php');
    }
    ?>

  • #2
    New Coder
    Join Date
    Jan 2009
    Posts
    58
    Thanks
    4
    Thanked 3 Times in 3 Posts
    simple!

    in your url

    Code:
    /index.php?page=shows?dj=autodj
    change to

    Code:
    /index.php?page=shows&dj=autodj
    for multiple Gets just use ? the first time and & for each one after!


    For your second question, i believe you are missing a closing }
    try adding one more at the end!
    Last edited by CalumK; 05-04-2009 at 09:11 PM.

  • #3
    New to the CF scene
    Join Date
    May 2009
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I understand that but where do I assign the &dj=autodj because I don't want it to include it on every page.

  • #4
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Are your pages in a directory called pages or not? The first snippet assumes no, the second snippet assumes yes.

    Your other question is a bit confusing: You want one page to come up for both DJs but then you say you want separate pages. Which one is it?

  • #5
    New Coder
    Join Date
    Jul 2008
    Posts
    96
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Well... I done my pages pretty different...

    PHP Code:
    <?php
    switch($_GET['item'])
    {
    case 
    'sig1'sig1(); break;
    case 
    'sig2'sig2(); break;
    }

    function 
    sig1()
    {
    include 
    'sources/sig1.php';
    }

    function 
    sig2()
    {
    include 
    'sources/sig2.php';
    }
    ?>
    the "include 'sources/whatever.php';" was where the actual page is

  • #6
    New to the CF scene
    Join Date
    May 2009
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I ended up doing this.

    PHP Code:
    <?php if(!isset($_GET['dj'])){
    include(
    'stats.php');
    echo 
    '<h2>Shows</h2>

    <div class="alpha">
    <a href="#123">123</a>
    <a href="#A">A</a>
    <a href="#B">B</a>
    <a href="#C">C</a>
    <a href="#D">D</a>
    <a href="#E">E</a>
    <a href="#F">F</a>
    <a href="#G">G</a>
    <a href="#H">H</a>
    <a href="#I">I</a>
    <a href="#J">J</a>
    <a href="#K">K</a>
    <a href="#L">L</a>
    <a href="#M">M</a>
    <a href="#N">N</a>
    <a href="#O">O</a>
    <a href="#P">P</a>
    <a href="#Q">Q</a>
    <a href="#R">R</a>
    <a href="#S">S</a>
    <a href="#T">T</a>
    <a href="#U">U</a>
    <a href="#V">V</a>
    <a href="#W">W</a>
    <a href="#X">X</a>
    <a href="#Y">Y</a>
    <a href="#Z">Z</a>
    </div>'
    ;

    echo 
    '<div id="shows">
    <div id="A">
    <p><a href="index.php?page=shows&dj=testdj">Test DJ</a><br />test</p><hr>

    </div>'
    ;} ?>

    <?php
    if (isset($_GET['dj'])) { 
    if(
    file_exists($_GET['dj'].".php")) { 
    include (
    $_GET['dj'].".php"); } 
    else { echo (
    '<p>The presenter you selected can not be found.</p>'); }
    }
    ?>

  • #7
    New Coder
    Join Date
    Jan 2009
    Posts
    58
    Thanks
    4
    Thanked 3 Times in 3 Posts
    well i must say im confused... what is all this?
    Code:
    <div class="alpha">
    <a href="#123">123</a>
    <a href="#A">A</a>
    <a href="#B">B</a>
    <a href="#C">C</a>
    <a href="#D">D</a>
    <a href="#E">E</a>
    <a href="#F">F</a>
    <a href="#G">G</a>
    <a href="#H">H</a>
    <a href="#I">I</a>
    <a href="#J">J</a>
    <a href="#K">K</a>
    <a href="#L">L</a>
    <a href="#M">M</a>
    <a href="#N">N</a>
    <a href="#O">O</a>
    <a href="#P">P</a>
    <a href="#Q">Q</a>
    <a href="#R">R</a>
    <a href="#S">S</a>
    <a href="#T">T</a>
    <a href="#U">U</a>
    <a href="#V">V</a>
    <a href="#W">W</a>
    <a href="#X">X</a>
    <a href="#Y">Y</a>
    <a href="#Z">Z</a>
    </div>
    I think your best bet is to use a Mysql database, and, query it with the dj's name ...
    I would explian it all here, but really googeling it will be more help.
    This way you could add info to the databse, and it would update easily...

  • #8
    New to the CF scene
    Join Date
    May 2009
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I don't know whether I am allowed to post a link to my testing site, I will post it and check with the rules. If it is against I will remove.

    This is what I am trying to do: http://www.tcsdesign.co.uk/radio/index.php?page=shows

  • #9
    New Coder
    Join Date
    Jan 2009
    Posts
    58
    Thanks
    4
    Thanked 3 Times in 3 Posts
    well, it looks good... Im mystified as to the proble you are having.. it all seems to work fine...
    your links copy across...
    so all you need to do, is display information relevant to the DJ yes?

    EDIT: in fact, your AutoDJ works perfctly...

    Is the problem solved?

  • #10
    New to the CF scene
    Join Date
    May 2009
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yeah it works now after you helped me from the first post. I have probably made it more complicated than it needs to be.

  • #11
    New Coder
    Join Date
    Jan 2009
    Posts
    58
    Thanks
    4
    Thanked 3 Times in 3 Posts
    oh.. good! glad to help


  •  

    Posting Permissions

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