forde52;10987071 wrote:
how will it decide what page you are on though?
Well, it seems I mistnerpreted what you wrote before
The idea of the navbar is that it is just one .php file stored on the server, and will display different links dependent on what page a user is on and wether they are logged in.
as having one single entry point, index.php, for your entire site, in which case you'd most likely have something like $_GET['page'] = 'whatever';
But when looking at your code I realize you do have several different entry points, so in each of them I'd define $topnav = 'filename' instead, and then from each separate file starting a different page
# decides which file to use for the navbar
$topnav = 'filename';
# code logic for the current page here
# ...
# outputs html, head and start of body elements, down to and including navbar.
require 'page_top.php';
# display content part for this page
# ...
# if necessary, inserts a page footer with might contain "contact us", nav links again,
# another ad
# closes body and html tags opened in page_top.php
require 'page_bottom.php';
Another way to do it is to handle page content similar to how you handle the navbar
# decides which file to use for the navbar
$topnav = 'filename';
# code logic for the current page here which assigns all output to $content
# ...
$content .= 'more stuff';
# outputs everything
# makes use of $navbar to display the proper navbar. uses $content to show the
# content part of the page.
require page.php;
Or even better, create functions for the various parts and call them
function display_head($enctype, $title, $navbar) { ... }
function display_content($content);
function display_foot();
But either way, the basic principle remains the same.