I have a shop page.
When the user selects a category they are taken to a shop category page which lists all the categories.
They click a submit button on a form using POST and it then takes them to a product page.
All works well except when they are on the product page and hit the back button they get a message to Confirm Form Resubmission. Is there any way to avoid this?
Yes, you can avoid the “Confirm Form Resubmission” message by using the POST-REDIRECT-GET pattern, where after processing the form, redirect the user to another page (product page) using a GET request instead of directly showing the product page after form submission.
Navigation should not use a post method form. You should use links or a get method form for navigation.
You should use a post method form when performing an action on the server, such as inserting, updating, deleting data, or sending an email. Any post method form and its form processing code should be on the same page. After successfully competing the post method form processing code, you should perform a redirect to the exact same url of the current page to cause a get request for that page. To go to any other page after that point, provide navigation links.
I originally used hrefs to send the user from the product listing page to the individual product page but found that I had messy urls. I suppose there is no alternative though as using forms are causing more problems, so going back to the hrefs.