Hello world,
I hope I made the title correct, but I need some sort of help/advise.
I have this code in my index.php to call php files to insert in the <div id=“main”>, it works fine but whenever I want to adopt some additional sample, say news system, this code is simple not compatible. Can you provide me a some sort of sample?
This is what I have got:
<!-- main starts here -->
<div id="main">
<?php
if (empty($_GET['cat']) )
{ $cat = 'pages'; }
else
{ $cat = ($_GET['cat']); }
if ( empty($_GET['page']) )
{ $page = 'home'; }
else
{ $page = preg_replace('/[^a-zA-Z0-9]/', '', $_GET['page']); }
if ( file_exists($cat . '/' . $page . '.php') )
{ include ($cat . '/' . $page . '.php'); }
else
{ include ('pages/error.inc.php'); }
?>
<!-- main ends here -->
</div>
This is where it came from:
INDEX.PHP
<!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" xml:lang="en" lang="en">
<head>
<meta ............ />
<link rel="stylesheet" ................ />
<?php include('counter.php'); ?>
<?php include('variables.php'); ?>
<title><?php echo $title ?></title>
</head>
<body>
<!-- wrap starts here -->
<div id="wrap">
<?php include('header.php'); ?>
<?php include('menu.php'); ?>
<!-- content-wrap starts here -->
<div id="content-wrap"><div id="content">
<!-- sidebar starts here -->
<?php include('sidebar.php'); ?>
<!-- main starts here -->
<div id="main">
<?php
if (empty($_GET['cat']) )
{ $cat = 'pages'; }
else
{ $cat = ($_GET['cat']); }
if ( empty($_GET['page']) )
{ $page = 'home'; }
else
{ $page = preg_replace('/[^a-zA-Z0-9]/', '', $_GET['page']); }
if ( file_exists($cat . '/' . $page . '.php') )
{ include ($cat . '/' . $page . '.php'); }
else
{ include ('pages/error.inc.php'); }
?>
<!-- main ends here -->
</div>
<!-- content-wrap ends here -->
</div></div>
<?php include('footer.php'); ?>
<!-- wrap ends here -->
</div>
</body>
</html>
Thanks in advance.
Regards,
Bong