Let say my form has 2 inputs
<input name="person_name" value="John" type="text" />
<input name="person_name" value="Jean" type="text" />
When submit the form, which “person_name” will I get? John or Jean?
And if I have
<input name="city" value="New York" type="text" />
<input name="City" value="New York" type="text" />
Will I get just “city” or “City” or both of them?
You will get two
person_namevalues (i.e. both John and Jean) sent to the server, then it is up to the server to figure out what to do about it. You can have as many elements in a form with the same name as you want; the[]notation is just notation that some frameworks use to pass the form’s structure to the server so that the server can unpack it without extra instructions and without the programmer having to differentiate between a list with one value and a single value.You’ll also get separate
cityandCityparameters and again, it will be up to the server code to figure out how it wants to handle that.From the HTML4 standard:
There’s nothing in there about selecting only one text input from several with the same
nameattribute.