I'm creating an admin area for my webpage, and I want to arrange some things in one php file, so I don't have to use different separated files. I have a manage.php file, where I want to put different things depending on how is it called. I'll give an example:
- If it's called like:
manage.php?action=users
, it will show me the users in my webpage. - If it's called like:
manage.php?action=roles
, it will show me the roles in my webpage. - ....
So, I assume this is done with the $_GET['action']
variable. So this would be the code inside my manage.php file:
<?php
include_once('layout.php');
if ($_GET['action'] === 'users') {
// The code I want to show...
} elseif ($_GET['action'] === 'roles') {
// The code I want to show...
} elseif ($_GET['action'] === 'categories') {
// The code I want to show...
} //etc...
?>
But I think that this is not a good way of doing this because I would have all my code put in different ifs... Is there a way for doing this in a 'cleaner' way? Or is this a good way of doing it?
Thanks!