Hi I'm trying to design something from the ground up, using several php sources as inspirations (as indicated by the TPL suffixes). I can't get it to work so please if you could indicate what I'm doing wrong here:

<?php
	
	if (!isset($_GET['page'])) 
	{
		$page = "news.php";
		include ($page);
	} else {
		$page = $_GET['page'];
		if ($page != 'news') {
			include ('header.tpl');
			include ($page.'.html');
			include ('footer.tpl');
		}
		else {
			include ('news.php');
		}
	}
?>

Basically I want to display news.php if there is no URL variable and/or if the URL variable is not given. Otherwise pick up and construct the site by adding up the includes that are shown (header + content + footer).

Nevermind, I figured out what was wrong. I needed to pass the variables with "page" in the URL, not by simply doing index.php?variable (index.php?page=variable should be used so that it works with this snippet).

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.