I’m trying to link my pages so I can switch from when to another through navigation bar but it’s not working and keeps reloading none stop without a result.
in my html nav bar :
JavaScript
x
<div id="topnav">
<a href="?page=index.php">Home</a>
<a href="?page=About.php">About</a>
<a href="?page=Contact.php">Contact</a>
</div>
in my index.php
JavaScript
if (!isset($_GET['page'])) {
include "index.php";
} else {
switch ($_GET['page']) {
case "About":
include "About.php";
break;
case "contact":
include "Contact.php";
break;
default:
include "index.php";
};
}
?> ```
Advertisement
Answer
The Switch cases don’t seem to match with the page parameters…
JavaScript
// amending the case values
switch ($_GET['page']) {
case "About.php":
include "About.php";
break;
case "Contact.php":
include "Contact.php";
break;
default:
include "index.php";
};