I have a piece of code I just wrote that detects if there is a user logged in and if [1] and [2] have any specific text in the string and then will relocate that person to another page if the values are met.
But I think my code is a little long winded. Is there a way to simplify what I have or is this the best I'll get?
if (!isset($_SESSION['user_id'])){
$dir = dirname($_SERVER['PHP_SELF']);
$dirs = explode('/', $dir);
if(isset($dirs[1])){
if (($dirs[1] == "account") || ($dirs[1] == "admin")){
header('Location: /');
}
}
if(isset($dirs[2])){
if(($dirs[2] == "account")){
header('Location: /');
}
}
}
Thanks in advance