I currently use the following script that checks if a page exists in my array and then opens it, else it opens my error.php
<?php
$page = $_GET['page'];
$pages = array('p_1',
'p_2',
'p_3',
'error');
if (!empty($page)) {
if(in_array($page, $pages)) {
$page .= '.php';
require_once('../' . $page . '');
}
}
else {
require_once('../error.php');
}
?>
Accidentally (until now I didn’t test it) I added a newpage.php in my site and forgot to add it in my array.
But my script instead of displaying my error.php it opened the newpage.php.
Where did I go wrong?
Thank you
Sorry to say it, but it is not possible. Not in this snippet of code. Search for requiring/including somewhere else
And, error.php shows only in case that
$_GET['page']is emptyis correct one