Best practice: one form per product is definitely the way to go.

Benefits:

  • It will save you the hassle of having to parse the data to figure out which product was clicked
  • It will reduce the size of data being posted

In your specific situation

If you only ever intend to have one form element, in this case a submit button, one form for all should work just fine.


My recommendation Do one form per product, and change your markup to something like:

<form method="post" action="">
    <input type="hidden" name="product_id" value="123">
    <button type="submit" name="action" value="add_to_cart">Add to Cart</button>
</form>

This will give you a much cleaner and usable POST. No parsing. And it will allow you to add more parameters in the future (size, color, quantity, etc).

Note: There's no technical benefit to using <button> vs. <input>, but as a programmer I find it cooler to work with action=='add_to_cart' than action=='Add to Cart'. Besides, I hate mixing presentation with logic. If one day you decide that it makes more sense for the button to say "Add" or if you want to use different languages, you could do so freely without having to worry about your back-end code.

Answer from Ayman Safadi on Stack Overflow
🌐
Reddit
reddit.com › r/webdev › how to handle multiple forms on a single page?
r/webdev on Reddit: How to handle multiple forms on a single page?
December 29, 2021 -

I have a scenario like this - user needs to confirm overwrites for multiple files - so the backend generates an html page with an arbitrary number of yes or no questions for each overwrite, somthing like this: "Should file "review.xml" be overwritten?" <button> Yes </button> <button> No </button> and so on for an as many files as needed. So the page looks like a list of questions, each with a yes or no button/radiobutton next to it. The user goes down the page clicking yes or no for each item then clicks submit at the end. The server then needs to receive the filename as well as a yes or no value or a boolean for each decision, so something like { "review.xml" : yes } {"topography.png" : no} etc. How can I accomplish this?

Discussions

php - How to place two forms on the same page? - Stack Overflow
Explore Stack Internal ... I want to place both register and login form on the same page. They both starts with: ... Also how to prevent executing first form if the second is busy, and vice versa (user clicks on both) My idea is to create a simple variable on starting process, for example $x = 1 and at the end of process $x = 0, so: ... Probably, there is a better way. ... So your question is not how to put two HTML ... More on stackoverflow.com
🌐 stackoverflow.com
php - Multiple HTML Forms on One Page - Stack Overflow
If I have multiple HTML tags with separate submit forms, how do I know which when was posted in the PHP file that processes the form's data? More on stackoverflow.com
🌐 stackoverflow.com
Why are two forms on one page bad? - User Experience Stack Exchange
I have been requested to put two forms on one page. The page is directed to from a "Pay Bill" link on our home page. The user currently lands on the page and they have a log in form with two inputs... More on ux.stackexchange.com
🌐 ux.stackexchange.com
July 29, 2014
Multiple Forms on One Page - PHP - SitePoint Forums | Web Development & Design Community
Under each Article on my website, members can post Comments. And beneath each Comment, other members can give the Comment a rating. So if there are 30 Comments, I would have 30 Forms!! What is the proper way to set up my Forms and Submit buttons so they work properly? Here is an example… More on sitepoint.com
🌐 sitepoint.com
0
July 19, 2014
Top answer
1 of 4
32

I feel like you've already answered your questions.

  1. One sign up form = one form tags.
  2. Multiple forms = many form tags.

Just don't nest them.

EDIT

Form tags are meant to hold a variety of fields (i.e. input tags) that you will eventually pass to a target URL using a GET or POST request.

Take this login form, for example:

<form action="login.php">
  <input id="name" type="text" name="name">
  <input id="passwd" type="password" name="passwd">
  <input type="submit" value="Login">
</form>

This has a login, a password, and a submit button. When the "Login" button (type = "submit") is pressed, the form will take that information and send it to another URL (in this case, "login.php", and that URL will handle the information accordingly (e.g. validate, sign you in, display captcha).

2 of 4
11

There is no reason why you can't have multiple forms on a single page. You just can't nest forms, because then the forms aren't able to identify which fields are for what.

Conceptually, if you need to have the information for two forms occupy the same section or area on your site (for example, if you were combining your sign-up and email list forms or something), you would use a single form and sort out the information from the POST variable on the other end. So long as you name things in a way that makes sense, you shouldn't even want nested forms to accomplish this.

Edit:

To further answer your question, a form tag, in its most basic use case, is used to submit data to a URL. The URL you choose to submit a form to typically receives that data and processes it in some way before taking action on that data, like storing the data in a database, or creating a new user based on a given username and password.

🌐
Kwesforms
kwesforms.com › docs › v2 › multiple-forms
<title>How to Build Multiple HTML Forms on One Page with KwesForms</title>
To have multiple forms on the same page, you must give each form class="kf-form". ... Notice anything wrong in our docs?
🌐
Help Center
support.demandbase.com › hc › en-us › articles › 360058007992-Enrich-Multiple-Forms-on-One-Page
Enrich Multiple Forms on One Page – Help Center
March 10, 2026 - These forms may be visible all at once or one at a time, based on your own business logic. Either way, you may want to use Demandbase on different forms on the same page. The details below describe the strategy to accomplish this.
Find elsewhere
🌐
Microsoft
social.msdn.microsoft.com › Forums › en-US › 1a0d1c6a-977a-48f1-8782-9db936bbc668 › can-i-add-multiple-form-to-one-single-html-page
can I add multiple form to one single html page | Microsoft Learn
September 25, 2019 - Yes, an html page can have multiple forms. The forms cannot be nested though. ... Of course, it can contain many forms in one html page.
Top answer
1 of 4
3

It's not explicitly two forms, since credentials are intuitive enough that users are able to recognize the username/password boxes with a low cognitive load.

I actually agree with having login forms on the same page, because if you always click on continue without logging in, you are just adding an extra step for that user.

But, just because they are on the same page doesn't mean they have to both be visible. One example I found has a tab you can switch between. Sure it's an extra click for the B Case users, but it's exactly not loading a new page.

Another example here, uses the same 2 boxes but allows you to input different types of data, and the login process is handled in the back-end.

I think 2 forms are bad on the same page if you have to fill both of them out. If you're only choosing one, that is fine because it's instead giving you options, like sign-up forms, e.g.:

  • https://stackoverflow.com/users/signup
  • https://vimeo.com/join
  • https://dribbble.com/signup?basic=true
2 of 4
1

In tasks where users need to go through a series of steps to complete a task, the key to improving the conversion or success rate is to reduce the complexity of the task, whether it is perceived or actual complexity.

Putting two forms in front of the user asks them to make a decision before they even get to assess the difficulty of the task, and puts a lot more information in front of them than what might be necessary. This is why you see lots of landing pages with large buttons asking the user to make a choice rather than putting two forms in front of them a letting them figure out what option that should choose.

I would suggest looking up topics and techniques on 'progressive disclosure' to get a better idea of the concept and see if you can apply it to your arguments.

🌐
SitePoint
sitepoint.com › php
Multiple Forms on One Page - PHP - SitePoint Forums | Web Development & Design Community
July 19, 2014 - Under each Article on my website, members can post Comments. And beneath each Comment, other members can give the Comment a rating. So if there are 30 Comments, I would have 30 Forms!! What is the proper way to set up my Forms and Submit buttons so they work properly? Here is an example…
🌐
ProcessWire
processwire.com › off topic › dev talk
Multiple forms on one page: bad practice? - Dev Talk - ProcessWire Support Forums
August 18, 2021 - Hi there, I received a design guide, where 3 different forms are placed on the same page. All of them have about 6–8 input fields and some radio buttons.The website is going to be from a doctor's office, specialized in geriatrics. So may be half of the website users, will be people above 70.
🌐
Netlify
answers.netlify.com › support
Is it possible to have two forms in one page? - Support - Netlify Support Forums
March 3, 2023 - Greetings, I am building up a website where there will be two forms in one page: one at the bottom, and one when a modal pops up when first loading the page. I have named both forms differently, but it seems to only detect one form. (Both are also using honey-pot).
🌐
Flodesk
help.flodesk.com › en › articles › 4748353
How to add the same inline form multiple times to a webpage
February 26, 2026 - Step 4. You're done! Repeat this process for each inline form you add to the same web page. You may add as many copies of your inline form to your page as you like, as long as each one has a dash and a unique string!
🌐
Marketing Nation
nation.marketo.com › t5 › product-discussions › how-to-add-a-global-form-multiple-forms-on-the-same-page › td-p › 333559
How to add a global form multiple forms on the same page | Community
March 10, 2023 - (The script to load the forms2.min.js goes separately on the header) Thanks in advance for any help 🙂 ... There’s no reason to consider the Render event at all from what I can see. Everything you need is there upon Ready. Got it. So, here's a working solution: HTML: <form class="mktoForm" data-formId="X005" data-formInstance="one"></form> <form class="mktoForm" data-formId="x005" data-formInstance="two"></form>
🌐
GitHub
gist.github.com › 5198218
An HTML page with multiple forms · GitHub
Save yoavweiss/5198218 to your computer and use it in GitHub Desktop. Download ZIP · An HTML page with multiple forms · Raw · multiple_forms.html · This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below.
🌐
Umbraco
our.umbraco.com › forum › umbraco-pro › contour › 6682-multiple-forms-on-same-page-a-problem
multiple forms on same page a problem
But if I want Search AND Contact Us, then I obviously nede two. How to achieve? ... The general rule to remember is that you can only have one server-side form (runat=server) on a page, but providing you don't nest your forms you can have as many HTML forms as you like along with this.
🌐
Fullybearded
fullybearded.com › articles › two-forms-in-one
Manage two forms in one page - FullyBearded
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Multiple Forms Example</title> </head> <body> <h1>Multiple Forms Example</h1> <form method="post"> <div> <h2>Basic Information</h2> </div> <div> <h2>Password Change</h2> </div> <button type="submit">Submit Both Forms</button> </form> </body> </html>
🌐
Quora
quora.com › Can-an-HTML-page-have-multiple-forms
Can an HTML page have multiple forms? - Quora
Answer (1 of 8): You can have as many forms as you need on a HTML page. As long as your script for processing the forms knows which form is which and processes them accordingly. You may have multiple scripts, one for each form.
🌐
Formr
formr.github.io › blog › multiple-forms-on-one-page
Multiple Forms on One Page - Formr
The solution? Multiple forms, and it's easier than ever with Formr. The first step is to instantiate (create) your forms, and give each its own name and ID. $profileForm = new Formr\Formr; $profileForm->id = 'UserProfile'; $passwordForm = new Formr\Formr; $passwordForm->id = 'ChangePassword';
🌐
Reddit
reddit.com › r/phphelp › need help with multiple forms on one page, here
r/PHPhelp on Reddit: Need help with multiple forms on one page, here
April 5, 2023 -

https://pastebin.com/qxigq13B

Apologies if my wording seems kind of vague here, but here goes:

For each row of mySql data that is returned, I want to make the row data its own form, include either a select menu (or a number input) and push them (both row data and input value) into an array on another file. The issue is, if I use $_GET or $_POST, the row items won't come through, and if I were to use $_SESSION, it would only take row data from the last form without including the value of the number/select input. Included is a relevant code snippet, with the number or select fields omitted.