Welcome back.
Now, what we need to do is that we need to work on the change passport functionality.
So in order to do that, we need to open up the account that we because this functionality, this feature
is in the is in the account that BHP and here in the account with BHP, we have the account here and
then if you scroll you'll find that we have uniform for changing the password.
So this form, let's start working on this for as usual, we need to say method.
We need to give this form method and the method is going to be post and then I'm going to also give
it a action.
So the action is, is just going to be the same page I'm going to say account that BHP.
And the password has any password and the confirmed password has also any confirmed password.
And then the button.
We need to give them a name.
I'm going to say your name.
And the name for this button is is going to be change, underscore or change password.
Very, very simple change password.
Now we need to work on the each part.
So add it up since this is a since this is a since this is a post request, we need to say if and then
we need to check the the post change password parameter.
I'm going to say a set and then I'm going to use a post.
I'm going to say is set post is set fast and I'm going to pass the change change password button change
password because the remember the button, I haven't given the button again, I have given the button
here and simple change password.
The next step is that we need to get the name.
We need to get the password and the confirm password from the fields, from these fields.
And to do this here in the inside, this statement, we need to say here, password.
Password.
Password is going to be password is going to be equal to most password, forced password.
And the confirm password I'm going to say here confirm password here gone for us or is going to be equal
to post pass confirm password bust, confirm, pass or and now what we need to do is that we need to
get a code that we already created, which is verifying that the password that the two passwords match
and also the password is not less than six characters and we already have that going in were just there.
If you go to the register, you'll find that we have this code.
So let's copy this code in order not to repeat this code.
So I'm going to copy this code and then I'm going to put it here, I'm going to copy it, and then I'm
going to be with you.
However, this code is going to be a little different if passwords don't match.
We need to redirect to the same page.
We need to say we need to say here their location account account that BHP and then error is equal to
password don't match.
And if the password is less than six characters, we need to say location and then account and then
your error is equal to password.
Must be at least six characters and else if if there are if there is no error, we need to say else
if no errors and before we continue in to make sure that we brace is the number of key.
Caleb is correct.
So here we have one, two, three.
And here one, two, three, four, one.
This is the closing.
This is the opening and this is the closing bracket and this is for the else.
So make sure that you don't have any problems.
And I'm going to push this code so that you see the structure of any well.
So here, in case we have no is no errors.
So if we don't have any errors, what we want to do is that we want to make agree.
So in order to make a query, we need to import here at the top, we need to include and then we need
to say server, server or slash connection, not BHP.
And then we need to use the connect here.
We need to say gone, you're gone and then prepare.
And then what we want to do is that we want to update the password.
So to update the password we need to say update date.
Users and then set password.
Password is equal to your question mark actually.
User password.
User underscore password.
User password is equal to a question mark.
Where, where, where or where.
Where user.
Wear user underscore.
Email.
Is equal to, again, question mark.
User email.
Equal to question mark.
And after that, we need to excuse this.
In order to execute this, we need to say we need to store this first.
In a statement I'm going to say here is t m t is equal to this and then we need to say is the empty.
And then first we need to bind mind param and we need to bind two things.
We need to bind the password and the email.
So we need to say user, the password is this password.
So first we need to bind the password.
So we need to say comma and then password for and then comma and then email.
So the email is in decision.
Remember, the email is in this issue.
So to get the email from the session we need to use a user email is equal to is equal to user.
Executive session session.
User underscore email.
And I'm going to say you that in.
And before.
Before I bind, we need to hash the password.
So I'm going to say in the five.
You know, I'm going to say Andy five and then I'm going to pass the password inside the device.
This is considered one of the best practices.
And if you want to know more about best practices, practices and security best practices, you can
take my course about that.
I recommend taking this course if you really want to know more about security best practices of BHP.
So after this, what do you want to do?
Is that what you want to execute?
So I'm going to say here is the empty and then how we just need to execute.
It's very similar.
If you if you check this out, you'll find that it's similar to two other code.
It's similar to this.
For example, we mine the program and then we execute and that's it.
But we don't hear the difference is that here we get the result, here we get we prepare and then bind
the amount of in execute and then we get the results.
But here since we are just updating, we don't need to do anything else.
We just need to check if password has been updated or not.
If this is true, we can here say Hey there.
And then.
Location and then.
And then I count.
That would be.
And their message is equal to past war.
Has been updated successfully.
Else.
If the password has not been updated, then we need to do the same.
We need to copy this exist and we need to copy this header and then we need to visit here and then we
need to say here.
And so the message here and then we need to say goodnight.
Good night of the password.
And now what we want to do is that we want to store messages.
So to store messages, to display actually messages.
So in order to display messages above the forum here, above this forum account, this forum, above
this forum I'm going to display to be the first feedback is going to be for the errors and the second
one will be for success messages.
So here I'm going to say class.
Text Center.
The Center and the restyle.
Color is going to be red and in between.
I'm going to say you're looking.
I'm going I'm going to see if if is said, get a visit.
Get.
Error if there is an error.
Error.
Then we need to display it.
We need to say echo.
Echo.
And then what do we want?
Echo.
We want to activate, get, get.
Air, get.
Here.
Pretty simple.
And in case of success, we need to copy the same exact paragraph, this paragraph, and then we need
to proceed below here.
And then we need to say, instead of red, I'm going to say green and then I'm going to say if it set,
yeah, get message, then we need to display the message.
So that's it.
Very simple.
Let me save and let's get on over to the browser to test.
So I'm going to hand it over to the browser and I'm going to refresh first and then I'm going to here
display.
As you can see here, it's going to be logged in successfully because I, I displayed the message because
in the log in in the log in, by the way, in logging, I passed upon logging in.
I passed this message logging in successfully and in case of error, couldn't verify the password.
So here, let me say I'm leaving here.
Say I'm leaving here.
Update my password.
So I'm going to type a new password.
I'm going to type a new password and see what's going to happen.
So I'm going to type here a new passport and then I'm going to click on Change Password.
And as you can see here, I have a very, very simple error.
It says account.
Not once was not found on the server.
And this is a very simple error.
There is because I have you in the form I should say.
I should say not in the form.
In the card.
I should say account.
Let me check one more time account this.
So there is here, I should say account.
I cannot be.
Air is equal to blah, blah, blah.
So that's it.
And another area that they have is here, I should say confirm Kimmel case password.
So we need to make sure that we don't have errors before like this one more time.
Let me now see about this.
So I'm going to save.
Let me go back and let's test.
So let me remove this.
Get request a refresh.
So now let me type a new password.
I'm going to here type in your password and test with a new password.
So if I click on change password, as you can see, it says that your password has been changed, has
been updated successfully.
And if password don't match, for example, if I type your password and in the second field I type another
password, it's going to say password don't match.
If I type a password, that's very short, meaning a type of password that is very, very short.
And then if you click on change password, it's going to say password must be at least six characters.
So this is how it works.
And this is it will allow users to change their passwords if they want to.
And another thing that they wanted to talk about is the is upon app on registering after the user register
we we will display this message user was not this one actually this one.
This one, you register successfully.
So we have this register message.
You can display it here in the account.
You can display in this account here.
Here.
Register here just to restore our success.
Let me say just to underscore success.
And here I'm going to say our sir.
Here.
We don't need actually here.
We don't need a.
We just need air.
So here is just our success.
So in the account, what we want to do is that we want to display this message above the above this
form.
In that account.
We want it displayed above the above.
Not this form above this.
Above this.
Me.
So here I'm going to say A.P. I'm going to copy this speech.
I'm going to copy this piece.
And then I'm going to say.
I'm going to say green.
And then I'm going to say if.
Get.
Resistor.
Underscore.
Success.
Then display the register.
Underscore success.
Similarly, with the log in, we have here a message.
Remember in the in the log in, we have error message.
We can say in a set of message in, let's say log in, underscore success and here that it's logging
success.
So in case of success, I'm going to display this message as well.
I'm going to copy this paragraph and let me copy this paragraph and then let me visit here.
And instead of instead of register six, I'm going to say log in success, log in, underscore success,
and here, log in, underscore success.
Laney save and let's test this.
So now in the in the page, if I if I got if I logout, if I tried to log in, let me log in now, maybe
log in one more time.
So if I log in.
So if I log in, guess what?
If they log in, a message will be displayed.
So if you click on log in, as you can see, it's going to say it's going to say you logged in successfully.
Similarly with the restriction, if you register successfully, another message will be displayed here.
So now our this area is complete the account info as well as the change password area.
Both are complete.