I am trying to use PHP include on my website but I am running into trouble...
To start this is my code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Future | Origins</title>
</head>
<body>
<?php
if (isset($_GET['p'])) {
$p = $_GET['p'];
include('include/header.php');
switch($p) {
case "about":
include('include/about.php');
break;
default:
$p = "include/main.php";
break;
}
include('include/footer.php');
}
?>
</body>
</html>
It only shows content for my index page if my URL is styled like
localhost/index.php?p=
I would like it to show content for my index page using the default
localhost
I don't have much knowledge of PHP and there never seems to be a straightforward solution. I am including multiple pages in my website using a switch case.
Many thanks
elsewith what to include when no parameter is given; right now you don't do anything whenpis not passed in the query string.