php - sql table join product notation system

one text

enter image description here Hello I have a rating system I want to check that the user who posts an opinion on a product on my site buys it well and I want to ensure that he can give an opinion on each item he has purchased only

here are the sql tables in image it is composed:[ users ][ details] [ sales] [product] [products]

the [details] table is the products that the user has ordered with the id of the order as well as all the ids of the products that order it the sales table is the user's orders in my case the only user who ordered is id number 9 and he performed 2 commands the user id and stored in the session under the name of $user $user['id'] I think the problem comes from the product id because the product id and transform into product name so like this $slug = slugify($name); $name = $_POST['name']; its fact that rather than having an id in the search bar there is the name of the product but always has the id of the product in the table of course well for the opinion system it's the same thing it"s $pid which retrieves the product id via the get and store in the $pid and pid returns the product name or computer for example instead of id=8 product=hp-pavilion-power-580-015na-gaming-pc

here I hope you understood me to help me thank you and the product table is id and users is id also there is nothing else to recup.enter image description here

Source