Hey guys,

I have been working on some code and have struck a problem, I tried to make the code as easy as possible to edit at a later date.

The issue comes when I include a config file from a directory for a certain page, this config file decides which document related to the current page to display, the issue is that when I try to include the documents from the config file I just get white space and the script seems to die but with NO errors.

Am I missing something?

index.php

<?php

	@include($_SERVER['DOCUMENT_ROOT']."/internal/config/global.php");

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>EZee Web Solutions</title>
<link rel="stylesheet" type="text/css" href="images/style.css" />
</head>
<body>

	<div id="main_wrapper">
	
		<div id="banner">
			
			<h1 class="title">Wolfet Tools</h1>
			
			<a style="border: none;" href="#"><img src="images/right.png" style="border: none; float: right;" alt="EZee Web Solutions" /></a>
			
		</div>
		
		<div id="sidebar">
			
			<?php
			
				get_module( "Members Panel" );
			
			?>
			
			<h3>Menu</h3>
				
			<ul>
				
				<li><a href="?">Home</a></li>
				<li><a href="#">Design</a></li>
				<li><a href="#">Programming</a></li>
				<li><a href="#">Portfolio</a></li>
				<li class="end"><a href="#">Contact</a></li>
				
			</ul>
			
		</div>
			
		<div id="banner_extension">
		
			
		
		</div>
			
			
			
		<div id="content">
			
			<?php
			
				if( !isset( $_GET['base'] ) ) {
					get_page("Home");
				}
				
				if( $_GET['base'] == "register" ) {
					get_page("Register");
				}
			
			?>
			
		</div>
		
		<div id="footer">
			
			
			
		</div>
	
	</div>

</body>
</html>

global.php

<?php

	function get_module( $module_name ) {
		$path = $_SERVER['DOCUMENT_ROOT'] . "/internal/modules/" . $module_name . "/config.php";
		if( !@include( $path ) ) {
			echo "<br /><span style=\"font-family: Sans-Serif; color: #ff0000;\"><p><b><u>FATAL ERROR:</u></b> There is an internal issue with the following module: <b>" . $module_name . "</b>.</p><p>Unfortuantely the path doesn't contain the required file: <b>" . $path . "</b>.</p></span><br />";
		}
	}
	
	function get_page( $page_name ) {
		$path = $_SERVER['DOCUMENT_ROOT'] . "/internal/pages/" . $page_name . "/config.php";
		if( !@include( $path ) ) {
			echo "<br /><span style=\"font-family: Sans-Serif; color: #ff0000;\"><p><b><u>FATAL ERROR:</u></b> There is an internal issue with the following page: <b>" . $page_name . "</b>.</p><p>Unfortuantely the path doesn't contain the required file: <b>" . $path . "</b>.</p></span><br />";
		}
	}

?>

config.php

<?php

	if( !isset( $_GET['page'] ) {
		include("form.php");
	}
	
	if( $_GET['page'] == "checkform" ) {
		include("validate.php");
	}

?>

<h1>Register</h1>
<p>Thankyou for signing up to use our tools. Please complete the following form in full. All fields marked with <font style="color: Red;">*</font> are required and <b>must</b> be filled in.</p>

<h3>Take your time</h3>
<p>Please take your time and know that this form is confidential and we will in no way share your details or use them in an inappropriate way.</p>

form.php

<h1>Register</h1>
<p>Thankyou for signing up to use our tools. Please complete the following form in full. All fields marked with <font style="color: Red;">*</font> are required and <b>must</b> be filled in.</p>

<h3>Take your time</h3>
<p>Please take your time and know that this form is confidential and we will in no way share your details or use them in an inappropriate way.</p>

Any help would be great, thanks.

if( !@include( $path ) ) {

That part of the syntax is totally wrong. I don't think that an include is not meant to be in an if statement. Also replace the include with the require function which does the same thing but with error reporting. Also I would advice removing those @ symbols. So the above quote should be the following:

if(file_exists($path)) {
require( $path );
} else {

Thanks buddy thats fixed it ;)

I think is better write in config.php so:

switch ($_GET['page']) {
    case 'checkform':
        include("validate.php");
   break;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.