Welcome back.
Now it's time to work on editing the product.
So here, if you if a user clicks on edit of a specific product, for example, this product, they
will be taken to this page.
And of course only admins will will be able to do this.
And then you can now as an admin you can edit and submit the new information.
For example, if you want to edit the title of the product or the description or the price or add a
special offer or the color, you can change any of these.
So let's work on this now in the edit product.
Remember, we have a form and in this form we need to give it here.
We need to give this form.
First, let me remove this ink type and then let me say your method.
The method is going to be post and the action is going to be the same page.
I'm going to say edit, underscore product page.
And then what we need to do is that we need to advocate here.
And as I told you earlier, we already have a lot of good and we don't have to worry about the code
because we already created so many.
We have created we have a lot of good and we can reuse that good.
So there is no need to type the code from scratch.
Remember in the account we have a code that edits that updates records here in the edit password.
In the change password we have this.
Good.
Let me show you where it is this good.
So let me copy actually only these lines and then I'm going to use them in the edit product here and
in this product first remember here we have if, if the if the the request is get we do we we we get
all of the products.
We we get that product, that specific product to display.
It's all data here.
However we need instead of saying else we can say else if it'll save and here we say else so we keep
else.
But we need to say else.
If so, else if.
Else if the request.
If the request is is here, let me show you the edit button so that in the bottom has a name edit product.
It is product.
Here it is product.
We can use this so we can edit underscore product.
Or edit let's say it is button because this is I think better in terms of.
It's discrete, it's meaningful in its body because by saying it is barren, you will understand that
the user, the admin clicked on the button edit button.
So here we to place the code which is going to do the following.
It is going to.
A year connected the database of update products products set.
And then what we want to set is that we want to get we want to set the new information.
So we need to get the the here we have the title.
We have title description, price, category and color.
Color and offer color and offer.
So let me create valuables with your variables.
I'm going to say here, first title or a title or name, let's say a title is equal to boss.
Title then we need description is equal to.
Lost.
And then.
Description.
And then we.
And you say
we can only say what else we have the price.
So the price is going to be equal to past price.
And then we need the offer and the colour offer is equal to cost.
Offer.
And then color.
Color is equal to.
Color.
And after the color, we have.
One, two, three, four, five.
We have.
The limit check with category, actually category.
So the category is going to be equal to last category category.
So here, three, three, six.
So he let me make sure that they are six.
So we have one, two, three.
Four, five, six.
So we have six.
That's it.
Now we have the six.
We need to pass them into the rescue ale statement here.
I'm going to say edit update products set.
And then what we want to set is that we want to set the new title.
I'm going to say that I'm going to say product underscore name is equal to is equal to question mark
and then.
And then comma and then product.
Project description.
Description is equal to question mark.
And then we want also to edit the product product underscore price and then question mark.
And then I'm going to add the rest in a new line.
And then here I'm going to also say product, product offer and then is equal to question mark and then
comma.
And then product product underscore color is equal to question mark.
And lastly, product category.
Is equal to question mark.
Where where?
This is very important.
Where Product Radack underscore I.D. is equal to question mark.
Now we need to bind to we need to say statement bind.
What we want to bind is that we want to bind the first name.
S Description.
S.
Rice.
S offer.
I'm going to also say s color s category s and then I'd I and then I'm going to pass all of these I'm
going to start with the product name.
I'm going to say product, product name and then comma, product description.
Actually, we don't have these variables.
We have these variables.
So I'm going to say title and then description and then price.
And then offer and then color and then category category.
And lastly, the product product I.D., but product I.D..
So now we have the product I.D. Lastly, we need to execute.
We need to say statement and then execute.
Execute and we can add, we can now take the user to another page so we can see Heather and then I'm
going to see a location.
Products.
And then that B2B.
And then I'm going to see myself here in the products.
We can add a variable.
That's going to display the, uh, the message.
Whenever you, whenever you want to display a message, you can display it here.
You can display it here, or you can do it.
I'm going to give you something very smart here, and it's going to just look amazing.
Leave me here for, say,
a year.
I'm going to say P and then I'm going to test I'm going to test the location of this.
So this if I go back, this, this is going to be displayed here.
So the if you want to display a message, you.