I added bbcode
[code][/code] tags around your code so that it will be displayed properly. Please do so yourself when posting code.
So, the posted code’s purpose is to display the requested item’s information, with an add to cart form. Previous comments still stand. If there is no item_id when this page gets requested, that’s an error. The code should also directly get just the data for the requested item.
The posted add to cart form should submit to the same page it is on, and ‘automatically’ propagate any existing get parameters. So, either the form processing code is what is doing the redirect and loosing the get parameter or all the posted code is inside of some other form. Nested forms are not valid, so the first opening
<form ... tag encountered is what determines where the form will submit to and if any existing get parameters will be carried in the url.