So another thing that we need to fix here is that we need to say here, user underscore email, not
just email.
Why?
The reason is because in the database, remember in the user stable, the the column for the email is
user underscore email.
And here we are using we are using it to connect to the database and I'm here checking I'm you're saying
we're user email is equal to something so we need to use this SQL user underscore email.
And also here are another thing that they wanted to fix here is they get error this get error.
If if we if the error if the the get request is not set, we are going to this is going to display a
an error.
This is going to split an error.
And instead of displaying the error message itself, so we need to say here we are if statements and
we need to say if.
Is sex only a set get.
Is said, get air.
If the air is set air, then I'm going to execute.
I'm going to hear you say echo and then echo this.
Good.
That's it.
So this good will never be executed unless there is an error message.
This is very, very important.
Finally, we need to continue working here after after the after we say here statement to bind by ram.
We need to excuse this.
I'm going to say is to empty and then execute.
Excuse this and we need to bind the we need to store the information in the session.
And I'm going to work on this later.
But for now, what we want to do is that we need to fix the code because the code now is getting complicated.
So here I'm going to say in order to fix this code, I'm going to say if password don't match, then
we are going to display an error here instead of saying another statement.
I'm going to say else if.
Else If the.
Else if the password is less than six characters, then I'm going to split another error here.
I'm going to say.
Else.
If there are no errors, are there?
If there are no errors, then I'm going to say ls.
And then I'm going to push all of this good insight.
All of this code will go inside the seals.
Here, I'm going to close the seals.
And here, inside the seals.
Here, I'm going to add a comment.
I'm going to say if.
There is no error.
Then we to display this at the closing racketeer and also the closing racketeer.
And remove it from here because this is going to make the code more organized.
So else else.
If there is no air, then we need to check whether check whether the there is a user with this email
or not here.
If this statement is going to check if there is there is a user with.
Already registered with registered with this email, then we cannot continue.
We need to send the user to the.
We need to display an error message.
Else else.
I'm going to add this code now.
All of this code now will go inside here and then I'm going to add a curly bracket and you need to double
check your code because there are so many curly braces.
If you get this wrong, it's not going to work.
So I want you to double check your code one more time.
So let me show you the code one more time.
If if user clicks on register, we get the data from the form and then check whether the email is whether
the password and the password confirm a match.
If they don't match, we display an error.
If there is another error, if the password is less than six characters, we also we also display an
error.
LS If there are no errors, by the way, these are the errors that I have used.
You can add more else ifs here if you want to check for more errors, but they think these are the most
important two errors that they want to I want the user to avoid.
The password don't match the password.
Less than six characters else.
If there are no errors, I'm going to first check whether there is an email, whether there is a user
with this email or not.
If there is a user with this email, then we need to take the user to the.
We needed to display an error message if there is a if there is no user with this email, if no user,
let me add your comment.
If no user registered.
With.
This email before then we can create an account with this email and password.
And finally here we need to say a statement excuse.
And then we need to check this by saying if if this is correct, if, if the the account has been created
successfully, what we want to do is that we need to get the data and display the date.
We need to store the user information in decision because at this point, the account has been created
successfully.
So I'm going to say here, user email is equal.
To the user email.
So here I'm going to say that user email is equal to the user email is equal to the email that they
use a registered with.
And this session I'm going to get another session with.
User
username.
Is equal to.
User name or name.
And we can also create a session.
A session?
Logged in.
Is equal to two.
And that's it.
And then we take the user to the account, which you can see here, there, and then location.
And then I count.
And then that BHP and I'm going to say here.
Register.
And then is equal to you register successfully.
That's it.
Else if there is a fear here, if account was created successfully.
Else.
Ills account couldn't could not be created for some reason.
So we need to display an error here.
Again, we need to use the header.
And then.
Register and then a location and then register.
And then that BHP.
And then air is equal to crude and could not get an account.
At the.
More Mitt.
And assets.
LC Or you can display anywhere you can.
You see, for example, here, there and then.
Location.
Register that BHP and then air.
And then you can say here, please fill in the form of the air.
The air is possibly at this point is that the past is not set.
So that's it.
And the last thing that we need to do is that we need to clear the account that BHP page.
So if you go through the account that BHP hope you will find that we have a page, full account, that
each email and we need to convert this to, we need to convert this to BHP.
We need to say account that BHP.
That's it for now.
I'm going to convert it to two, account three and then later I'm going to display the information there.
And finally here actually if I use the header in the LS it, it's not going to allow me to enter the
page anyways because the is set here.
Whenever I enter the page it's always going to be not set.
The post is not going to be set.
So here actually I shouldn't have this code at all.
I should remove this completely.
I should remove this code and I shouldn't add this code for now.
Let me save and we can have another code that's going to to check whether the user is logged in or not
in order to.
To avoid.
They used to go to the area.
So if they are lucky.
But there is no need for this now.
Here we need to say session start.
This is the last thing that we need.
And the last thing that I'm going to do is that here we need to say statement and then store result.
This is very important.
You need to call a result.
Otherwise it's not going to work.
This is not going to work.
And by the way, here after this if statement, we need to check whether the user is logged in or not.
But I'm going to work on this later because I don't want to confuse you right now.
So let me now head on over to the browser and test.
So first we need to go to the Register page because as you can see, there is no link for the register.
So I'm going to say register, you just turn that feed and then maybe it's an account.
So leaving your with an account and I'm going to type everything correctly.
And let me here create an account.
So if you click on register and if everything is fine, as you can see, it's going to take me to the
account page and now in the database I should find my account so my account has been created.
Now, let me try.
Let me go to the register page and try to.
To test for other possible scenarios.
Now, if you go to the Register page, the first problem that they have is that they will be able to
go through to the register page even though I already have created an account.
So this is a problem that I'm going to work on shortly, but first, let's test the problems.
So the first problem is that if you click on register without feeling the form, it's not going to allow
you which which is great.
And if you try to use an account with the, with the same email, for example, if you're trying to
create an account with this email, let me test.
It's not going to allow you.
Let me show you this.
So if you click on register, it's going to say your user with this email already exists.
So this is going to protect the form from getting to accounts with the same email.
If you test with the let's say.
Let's say that the user did not type did not out the let's say the emails.
The passwords don't match.
So if I type your password and in the second field, I'm going to type another password that don't match.
If you click on register, it's going to say here, password don't match.
So you can use this and commit this thing this multiple times in order to avoid any problems with the
or for.
The last problem is that that we need to fix is the registration.
So here in the form we need to say we need to say ILS if and then we need to check this session.
We need to say session is set.
A set session.
Session, locked in, logged in.
Remember, we have here a key call logged in.
So if user if the logged in is if user is logged in, then what we need to do is that we need to say
here that location, location and then index or account actually account account dot BHP and we need
to take the user to the account that we because at this point the user has already registered and we
need to exit.
So let me test this.
So now I'm locked in research.
So if I try to go to the registration page, I shouldn't be able to enter the.
As you can see, I will not be able to enter the registration page leaving here, say register one more
time registered at BHP.
And if I try to go to the register, it's not going to allow me because this is going to protect the
the registration page.
I'm going to say here, if a user has already registered.
Then.
Take user to account which.
And also in the registration page, we have a link here.
We have a link for log in.
So we need to to activate this link.
I'm going to say here, Ashraf, and this is going to take the user to the log in that which is the
page that I'm going to work on.
So now our registration system is complete.