Student Listing: Adding Navigation Menu - Updating Pages to use Nav Menu
We need to modify the following pages to use the new navigation menu:
index.phpstudentdetails.phpunauthorizedaccess.phpsignup.phplogin.phpaddstudent.phpremovestudent.phpeditstudent.php
Let's take them one at a time and I'll point out additional changes we will make as appropriate.
index.php - Student Listing: Modify to use Nav Menu
The first thing we want to do is open the index.php script and include the pagetitle.php script at the top of the script:
1 2 3 4 5 6 | |
Next we need to make the following changes for displaying the <title>:
1 2 3 4 5 6 7 8 9 10 11 | |
Next, right below the <body> element, include the navmenu.php script:
1 2 3 4 5 6 | |
Since We already have the functionality to add a student from the navbar when a user with administrative privileges is logged in, let’s remove the link to add a new student, just below the <div class="card-body"> line and replace our header with $page_title :
1 2 3 4 5 6 7 8 9 10 11 12 | |
Currently, we always show the trashcan icon for each student row:
1 2 3 4 5 6 7 8 9 10 11 12 | |
We need to modify the logic to only show the trashcan link if someone is logged in with administrative privilieges. Therefore, make the following modifications:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | |
studentdetails.php - Student Listing: Modify to use Nav Menu
Again, we want to include the pagetitle.php script at the top of the script. Open up studentdetails.php and add the following code to the to top of the script:
1 2 3 4 5 6 | |
Next we need to make the following changes for displaying the <title>:
1 2 3 4 5 6 7 8 9 10 11 | |
Since We already have the functionality to link back to the home page from the navbar, let’s remove the link to index.php, just below the <div class="card-body"> line and replace it with a header with the title set in $page_title, and a horizontal line:
1 2 3 4 5 6 7 8 9 10 11 12 13 | |
Now let's only show the link to edit a student if the user has admin privileges or if the user is this student. Add the following code starting right after the second closing </div> tag:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | |
unauthorizedaccess.php - Student Listing: Modify to use Nav Menu
All we need to do for the unauthorizedaccess.php script is to included the navmenu.php script right after the opening <body> tag:
1 2 3 4 5 6 7 | |
signup.php - Student Listing: Modify to use Nav Menu
Again, all we need to do for the signup.php script is to include the navmenu.php script right after the opening <body> tag:
1 2 3 4 5 6 7 | |
login.php - Student Listing: Modify to use Nav Menu
Again, all we need to do for the login.php script is to include the navmenu.php script right after the opening <body> tag:
1 2 3 4 5 6 7 | |
addstudent.php - Student Listing: Modify to use Nav Menu
Open up addstudent.php. First, let's include the navmenu.php script right below the opening <body> element:
1 2 3 4 | |
Since We already have the functionality to link back to the home page from the navbar, let’s remove the link to index.php, just below the <div class="card-body"> line:
1 2 3 4 5 6 7 8 9 10 11 12 | |
removestudent.php - Student Listing: Modify to use Nav Menu
Open up removestudent.php. All we need to do is include the navmenu.php script right below the opening <body> element:
1 2 3 4 | |
editstudent.php - Student Listing: Modify to use Nav Menu
Open up editstudent.php. First, let's include the navmenu.php script right below the opening <body> element:
1 2 3 4 | |
Since We already have the functionality to link back to the home page from the navbar, let’s remove the link to index.php, just below the <div class="card-body"> line:
1 2 3 4 5 6 7 8 9 10 11 12 | |