Welcome back.
Now, what we need to do is that we need to organize the template further so that I will be able to
create other pages and work on other pages.
So in this template I have the side menu and this is the side menu and we need also to create a header.
So I'm going to create a new file in the admin here called header that BHP.
And now what I'm going to do is that I'm going to move from the, from the log in.
What I'm going to do is that I'm going to move the header, which is this which starts from here all
the way to.
All the way to this body and this sign out.
So this is the header.
This is the header.
Let me copy it.
Elaine You remove it from here.
Elaine added to the header here in the header.
And again, this here is inside the admin.
This is not the header that's inside the layout.
So this is different.
Now we need to import a header here.
So here what I'm going to do is that I'm going to say BHP and then include.
And then what we want to include is that we want to include the header header that BHP either that BHP
and similarly for the for the side menu, remember we have here inside menu, I'm going to add the side
menu on a in a different page.
I have already done that here.
The side menu let me work on I now let's work on the header itself.
So for the header we need to add a log out, a log out code.
So for the look out for this log out.
What we need to do is that we need to say here we need to say a trip and the entry of will log the user
out.
So this trip is going to be equal to log out dot BHP and then I'm going to create a new file called
logout here.
I'm going to create a new file admin new file log out dot BHP.
I remember the log out is pretty simple.
The log out if you go to the account, if you go to the account you'll find that we have here.
They log out.
This has been log out.
Good, this is a log output so we can copy this good and then we can paste it in the log output.
BHP, we can use a BHP and then we can paste this code.
However, we need to edit a few things.
First, the log out get is in the header.
Log out that PDB and then question mark.
Log out is equal, let's say, to one and a year.
If if a set session add the main admin underscore logged in and then here unset add the main underscore
logged in and then unset admin email, admin, email.
And here on set also admin admin.
Our name and then header location log in.
We take the user to the log page and it's similar by the way, again, if resizing this because it's
similar to the account, there's basically there is no difference.
The only difference is the keys that we stored.
That we saw it in this session.
So here, remember in the lockout we have here, this lockout button is lockout button and this lockout
button says account that BHP question mark lockout is equal to one.
Pretty simple.
So let me now save Sable.
And by the way, here you can say a set ad is set, log out is set, get log out.
And you can also check.
You can see and.
And log out or get get.
Log out.
Log book is equal to one.
But this is not.
This is not this is not mandatory because it doesn't matter.
As soon as they use it.
Well, our goal is that as soon as the user clicks on this button, we just log them out for there is
no need to check this, but this is just for the sake of explanation.
So let me now save everything and show you how this is going to work.
Now, let me go to the log in page.
I'm going to go to the actually, I cannot go to the log in page because I am logged in.
So let me continue working and then I'm going to show you the log out.
So let me work on the index.
In the index.
In the index here.
What we want to do is that we need to repeat the same the design design pattern.
So we need to remove this header.
All of this code must be removed.
And instead of this good.
Until they hit her.
Remove the skirt.
And then what you need to do is that you need to adhere BHP, BHP and then include.
Include.
And then what we want to include is that we want to include the header.
We need to say header that BHP.
And then that's it.
And by the way, in the header, something very important to add in the header is the.
Is the session start?
We need to say here BHP.
BHP and then.
Session.
Start.
Because we want to use the session on all pages.
Also in the log out we I forgot to say session because here I'm using this session.
So I also need to say here session start.
Session start.
Now back to the to the index.
In the index, we need to remove the side menu here.
And instead of using this static side menu, we need to use the side menu file.
So this side menu file will contain the side menu.
So I'm going to remove it from here.
What we need to remove is that we need to remove this now because the side menu record is in the side
menu starts from there now.
Therefore in the index, we just need to remove this now.
From here, all the way to the end of the nav.
Which is this?
Which.
Which let me show you which is this.
And then after you remove it, we just need to say here we just need to say BHP and then include.
Include.
Side menu.
Include and then side.
Many.
That BHP, I mean you're limited.
I was able let's say been over to the browser and now let me refresh.
And as you can see now in the dashboard, if I click on logout, I will be taken to the login page.
However, I having a problem in say the session had already been started.
So in line one in the header.
So in the header we have a problem here.
It says the the session has already been started.
I think the reason is because in the log in we or we have also a session start.
So we need to remove it from here because we shouldn't be using the we shouldn't be using the position
twice.
So it's better to add the session, start in the header page and not in every single page.
So it worked.
Let me refresh now.
The air should be gone.
Now let me log in.
If I log in and then if I say admin at email that HP and log in.
Now I will be able to go to the dashboard and if I click on log out I will be taken to here.
It did not take me actually to the to the, to the login page.
I have a problem again in the in the logout.
So if you get nothing here then we have a problem.
And the problem is that here I should say instead of saying admin id if say saying admin, it is equal
to user ID, we need to say admin, it is equal to admin 80 because here we are using the admin I.D.
not to use a and here we need also to say admin name and admin email.
And another problem that we have.
Is that.
And we should also move the header from here to the top.
We need to add that at the top because the header contains the session start and we need this recession
start at the top.
Let me now say about let's say a bit over to the browser and replace.
Now as you can see, there is no problem.
Leonie here log in.
Click on admin at.
Let me talk to you my email on my password.
Let me log in.
So if I log in, I will be taken to the dashboard.
Now, if you click a log out, I will be taken to the log in.
However, there's still a very small problem, which is a year the log out button.
This log out button is being displayed if you need to remove it from the log in page and to remove it
from the log in page, we can add the header.
We can add a code that is going to hide it.
So we can here say BHP and then we can see if.
Is.
Sir.
Session.
Ad man logged.
In.
If admin is locked in, then I'm going to display this code.
Then I'm not going to display this.
But if I mean is if admin is is logged in, then we need to display this equipment is not logged in
then we shouldn't be displaying this.
So here I'm also I'm only going to display this code if admin is logging.
So now let me save.
I'm showing you that this button will be hidden from the login page.
So as you can see, the logging of the log out button does doesn't exist because now we are in the log
a page and finally we need to protect the index and to protect the index, we, we should add a code
at the top that's going to protect the page.
And to do this.
We can't create a file that's going to do this or we can adequately let's advocate here for now I'm
going to say B2B and then I'm going to say if.
Session is the same code that we we added before we just added we to the session.
Admin logged in, admin log in and then instead of saying admin logged in, I'm going to say if admin
is not, I'm going to say here exclamation, which means that which means that the admin is not logged.
So if the admin is not logged in then we need to say header location.
Log in.
But.
HP And we also need to say exit.
And he logged logged in.
Be careful with the key here.
The key is admin underscore logged in.
Let me click on table and let me test.
So I'm going to go back to the index and let me go now to the log in.
Laney log out because I'm logged in.
Actually leave me log in one more time.
So I'm going to log in again.
And then.
I'm going to guess here.
First, I'm going to click on Look Out.
Let me see what's going to happen if I click a log out.
I will be logged out.
Now let me try to go through the index without logging in.
Now I've looked at let me try to go to the index.
If I try to go to the index.
I will not be able to index again.
I will not be able to, because now the index page has been protected, which is very, very important.