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!


Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 23

Thread: PHP Includes

  1. #11
    Join Date
    Mar 2009
    Location
    Western Australia
    Posts
    386
    Tokens
    0

    Default

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    
    <head profile="http://gmpg.org/xfn/11">
    	<title>Zipped Files | Downloads | Tutorials | Hosting</title>	
    	<link rel="icon" href="image/favicon.ico" type="image/x-icon" />
    	<link rel="stylesheet" href="style.css" type="text/css" media="screen" />
    	<meta http-equiv="cache-control" content="no-cache" />
    	<meta http-equiv="content-type" content="text/html; charset=utf-8" />
    	<meta http-equiv="content-language" content="en-gb" />
    	<meta http-equiv="imagetoolbar" content="false" />
    	<meta http-equiv="pragma" content="no-cache" />
    	<meta name="author" content="Christopher Robinson" />
    	<meta name="copyright" content="Copyright (c) Christopher Robinson 2005 - 2007" />
    	<meta name="description" content=""/>
    	<meta name="keywords" content="" />	
    	<meta name="last-modified" content="Thursday, 01 February 2007 12:00:00 GMT" />
    	<meta name="mssmarttagspreventparsing" content="true" />	
    	<meta name="robots" content="index, follow, noarchive" />
    	<meta name="revisit-after" content="7 days" />
    </head>
    
    <body>
    	<div id="container">
    		<div id="navigation">
    			<ul>
    <li><a href="index.php?page=contact">Contact</a>
    <li><a href="index.php?page=login">Login</a>
                                    <li><a href="index.php?page=tutorials">Tutorials</a></li>
    				
    				<li><a href="index.php?page=hosting">Hosting</a></li>
    				<li><a href="index.php?page=download">Downloads</a>
                                    <li><a href="index.php?page=home">Home</a>  
    		</div>
    		<div id="content">
    
    
    			
    <br>
    <?php
    if (!isset($page))
    {
    include("blank.php");
    } 
    if(file_exists($_GET['page'].".php")){
        include $_GET['page'].'.php';    
    }
    if(file_exists($_GET['page'].".html")){
        include $_GET['page'].'.html';
    }
    if(file_exists($_GET['page'].".txt")){
        include $_GET['page'].'.txt';
    }
    if(file_exists($_GET['page']."folder/.php")){
        include $_GET['page'].'/system/login.php';
    }
    elseif (isset($page) && !@include("$page"))
                 {
                 echo "Error Page not found!";
         } 
    ?> 
    
    	
    		
    			
    		</div>
    		<div id="footer">
    			<center>Zipped Files - 2009</a> 
    			&nbsp;&nbsp;|&nbsp;&nbsp;
    			Designed by <a href="http://www.edg3.co.uk/" title="Freelance Web Site Design">edg3.co.uk</a>
    			
    		</div>
    	</div>
    </body>
    </html>

  2. #12
    Join Date
    Dec 2005
    Location
    Australia
    Posts
    693
    Tokens
    0

    Default

    elseif (isset($page) && !@include("$page"))
    Incorrect usage of include.

    Use file_exists instead.

    Also, change the elseif to just an if. There's too many if statements there for it to be executed correctly.

    edit:
    oh and it displays a blank page because of this line..
    include("blank.php");
    Last edited by Heinous; 02-09-2009 at 01:11 PM.
    XHTML, CSS, AJAX, JS, php, MySQL.

    --

    HxF moderators can't read timestamps.

  3. #13
    Join Date
    Apr 2008
    Location
    Derby
    Posts
    4,668
    Tokens
    262

    Latest Awards:

    Default

    PHP Code:
    include("backend/show_news.php"); 
    Try changing it to the relative link as oppose to the other kind

    If it doesn't work, im sorry

  4. #14
    Join Date
    Mar 2009
    Location
    Western Australia
    Posts
    386
    Tokens
    0

    Default

    Quote Originally Posted by Heinous View Post
    Incorrect usage of include.

    Use file_exists instead.

    Also, change the elseif to just an if. There's too many if statements there for it to be executed correctly.

    edit:
    oh and it displays a blank page because of this line..
    So like
    PHP Code:
    if (file_exists($filename)) { 
    Quote Originally Posted by iApps View Post
    PHP Code:
    include("backend/show_news.php"); 
    Try changing it to the relative link as oppose to the other kind

    If it doesn't work, im sorry
    Thanks Iapps but cutenews it working fine!

  5. #15
    Join Date
    Dec 2005
    Location
    Australia
    Posts
    693
    Tokens
    0

    Default

    Um, more or less..

    PHP Code:
    elseif (isset($page) && !@include("$page")) { 
    becomes..
    PHP Code:
    if (isset($page) and file_exists($page) === false) { 
    XHTML, CSS, AJAX, JS, php, MySQL.

    --

    HxF moderators can't read timestamps.

  6. #16
    Join Date
    Mar 2009
    Location
    Western Australia
    Posts
    386
    Tokens
    0

    Default

    Made the change and still "page not found"

  7. #17
    Join Date
    Dec 2005
    Location
    Australia
    Posts
    693
    Tokens
    0

    Default

    PHP Code:
    <?php
    if (isset($_GET['page']) === true) {
        
    $page stripslashes($_GET['page']);
        if (
    file_exists($page '.php') === true) {
            include 
    $page '.php';
        } elseif (
    file_exists($page '.html') === true) {
            include 
    $page '.html';
        } elseif (
    file_exists($page '.txt') === true) {
            include 
    $page '.txt';
        } else {
            echo 
    'Error: page not found.';
        }
    } else {
        include(
    'blank.php');
    }
    ?>
    Replace your current PHP code with that. It's more efficient and.. correct. Let me know if it still occurs afterwards.
    XHTML, CSS, AJAX, JS, php, MySQL.

    --

    HxF moderators can't read timestamps.

  8. #18
    Join Date
    Mar 2009
    Location
    Western Australia
    Posts
    386
    Tokens
    0

    Default

    Thank you for your help, it doesn't occur anymore.. one last thing say in the navigater I had index.php?page=foo which is in the same directory as index, title as foo.php how would I link to say /folder/file.php ?

  9. #19
    Join Date
    Dec 2005
    Location
    Australia
    Posts
    693
    Tokens
    0

    Default

    index.php?page=/folder/file

    Should work.
    XHTML, CSS, AJAX, JS, php, MySQL.

    --

    HxF moderators can't read timestamps.

  10. #20
    Join Date
    Mar 2009
    Location
    Western Australia
    Posts
    386
    Tokens
    0

    Default

    Ok that doesn't work and also when I load index.php it shows blank content instead of home.php

Page 2 of 3 FirstFirst 123 LastLast

Posting Permissions

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