I am learning my way around php applying some Separation of Concerns. I am at localhost/admin/index.php.
I have my index.php as follows
...
$admin = new Admin();
if($_SESSION["user_privilege"]!=100) {
header("Location: error.php");
exit;
}
else
include('views/admin_panel.php');
'admin_panel.php'
!DOCTYPE html>
<html>
<head>
<title> Admin Panel </title>
</head>
<body>
<?php
/** Create an array of admin features with the key being the get url
* and the value being the feature
*/
$tasks = array('user_accounts'=> 'User account Management','products' => 'Product management','categories' => 'Category Management','static_pages'=>'Page creation and deletion', 'customer_query'=> 'Answer Queries from users');
echo '<ul>';
foreach($tasks as $key => $val) {
echo '<li><a href="index.php?'.$key.'">'.$val.'</a></li>';
}
echo '</ul>';
?>
</body>
</html>
That's simple stuff. Now, if I have a GET request to, say index.php?user_accounts, and I have that template at 'views/user_accounts.php', I've added the following lines to index.php
if ($admin->clickAction("user_accounts") == true)
include('views/user_accounts.php');
#The functions are defined in the model
But, is this the right way to do it? I guess not, because the previously included admin_panel also appears with the user_accounts template which is not what I was hoping for.