I have an simple PHP script that includes a file, when it's requested via URL.
for an example: http://example.com/index.php?page=about So this includes the page about.inc
This is working, but i have another problem. When someone visits the homepage so just: http://example.com/ . It will show me this
Undefined index: beta in /home/admin/domains/mydomainname.nl/public_html/index.php on line 3
That is:
$page = $_GET['page'];
I know I can disable the error notice in PHP, but this is not a solution but a workaround.
$path = 'app/inc/pages/dynamic/';
$page = $_GET['page'];
$php = '.inc';
$both = $path . $page . $php;
$pages = array('index', 'home', 'about', 'contact');
if (!empty($page)) {
if(in_array($page,$pages)) {
//$page .= '.php';
include($both);
}
else {
include('app/inc/pages/dynamic/404.inc');
}
}
else {
include('app/inc/pages/dynamic/home.inc');
}
}
It does include the homepage via
else {
include('app/inc/pages/dynamic/home.inc');
}
My question is how to solve this?