I have the following script to dynamically include pages into the index.php:
<?php
$_GET["page"] = (isset($_GET["page"])) ? $_GET["page"] : "home.php";
$page = $_GET['page'];
$pages = array('home', 'solutions', 'projects', 'about', 'contact');
if (!empty($page)) {
if(in_array($page,$pages)) {
$page .= '.php';
include($page);
}
else {
echo 'Page not found. Return to
<a href="index.php">index</a>';
}
}
else {
include("home.php");
}
?>
When I type in “localhost/mysitename/index.php” in the adress bar of the browser I get the index.php loading up good but in the content area where the dynamic includes should happen it says: “Page not found. Return to index”.So how can I set a default page to be included when the index.php is being loaded? I ‘m pretty new to PHP.
You have an extra
.phphereShould be