Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2006
    Location
    Boro
    Posts
    841
    Tokens
    1,650

    Latest Awards:

    Default Can anyone take a look at this please!

    i cant get this f'in include to work properly.

    can anyone help plz


    the page is called testing btw.

    www.bonxy.co.uk/testing.php

    and here is the code...

    <center>

    <a href="testing.php?page=home">Home</a> 1

    <a href="testing.php?page=blog">blog</a> 1

    <a href="testing.php?page=ch">ch</a>

    <br>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    <?php
    $_GET['page'];
    switch($page)
    {
    case "home":
    include('pages/home.php');
    break;
    case "blog":
    include('blog.php');
    break;
    case "ch":
    include('ch.php');
    break;
    default:
    include('pages/home.php');
    break;
    }
    ?>


    any help will be greatful.

    xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    *hi*


    Edited by Bonxy



  2. #2
    Join Date
    May 2007
    Location
    Brisbane, Australia
    Posts
    796
    Tokens
    0

    Default

    Links:
    <a href="testing.php?page=home">Home</a> 1

    <a href="testing.php?page=blog">blog</a> 1

    <a href="testing.php?page=ch">ch</a>

    &
    make ur content scipt this:

    <?php
    $page = $_GET['page'];
    if(!isset($page))
    {
    include("home.php");//Home page..
    }
    else if(file_exists("" . $page . ".php"))
    {
    include("" . $page . ".php");
    }
    else
    {
    echo("<h1>Error..</h1>The file <strong>" . $page . ".php</strong> was not found.");
    }
    ?>
    Thanks,
    Chris
    Free Image Uploading

    __________________


    [/url]

    [/FONT]

  3. #3
    Join Date
    Mar 2008
    Location
    Swindon, UK
    Posts
    1,274
    Tokens
    187
    Habbo
    :Ltd

    Latest Awards:

    Default

    PHP Code:
    <?php
    $page 
    $_GET['page'];
    if(!isset(
    $page))
    {
    include(
    "home.php");//Home page..
    }
    else if(
    file_exists("" $page ".php"))
    {
    include(
    "" $page ".php");
    }
    else
    {
    echo(
    "<h1>Error..</h1>The file <strong>" $page ".php</strong> was not found.");
    }
    ?>
    Don't know why you did double double quotes... lols This will also work, but I believe his version will too...

    PHP Code:
    <?php
    if ( $_GET 'page' ] === '' )
    {
        include( 
    'home.php' );
    }
    elseif ( 
    $_GET 'page' ] !== '' )
    {
        if ( isset ( 
    $_GET 'page' ] ) )
        {
            if ( 
    file_exists $_GET 'page' ] . '.php' ) )
            {
                include ( 
    $_GET 'page' ] . '.php' );
            }
            else
            {
                echo ( 
    '404, page wasn\'t located' ); 
                
    // include ( '404.html' );
            
    }
        }
    }
    ?>
    Though the method you want to do using switch can be also used.
    PHP Code:
    <?php
    $_GET
    ['page'];  
    switch(
    $page)
    {
    case 
    "home":
    include(
    'pages/home.php');
    break;
    case 
    "blog":
    include(
    'blog.php');
    break;
    case 
    "ch":
    include(
    'ch.php');
    break;
    default:
    include(
    'pages/home.php');
    break;
    }
    ?>
    I do a clean version for you;
    PHP Code:
    <?php
    switch ( $_GET 'page' ] )
    {
        case 
    'home':
            include ( 
    'pages/home.php' );
        break;
        
        case 
    'blog':
            include ( 
    'blog.php' );
        break;
        
        case 
    'ch':
            include ( 
    'ch.php' );
        break;
        
        default:
            include ( 
    'pages/home.php' );

    }
    ?>
    or... I do it this way..
    PHP Code:
    <?php
    $pages_allowed 
    = array ( 'home',
                             
    'blog',
                             
    'ch' 
                             
    );

    if ( 
    $_GET 'page' ] === '' )
    {
        include ( 
    'home.php' );
    }
    elseif ( 
    $_GET 'page' ] !== '' )
    {
        for ( 
    $i 0$i <= sizeof $pages_allowed ); $i++ );
        {
            if ( 
    $pages_allowed $i ] === ( $_GET 'page' ] ) || ( $_POST 'page' ] ) )
            {
                if ( 
    file_exists $pages_allowed $i ] . '.php' ) )
                {
                    
    // It should exist as we allowed it in our list etc but yeah.
                    
    include ( $pages_allowed $i ] . '.php' );
                }
                else
                {
                    echo ( 
    '404, page wasn\'t located' ); 
                    
    // include ( '404.html' );
                
    }
            }
            else
            {
                echo ( 
    'The page you requested is not in our allowed list! or 404' );
            }
        }
    }
    ?>
    Last edited by Protege; 05-07-2008 at 11:51 PM.
    Hi, names James. I am a web developer.

Posting Permissions

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