Is there a way to get the value of the name attribute in the form tag? I'm using PHP and don't see it in $_POST
.
Asked
Active
Viewed 1.2k times
4

hakre
- 193,403
- 52
- 435
- 836

StackOverflowNewbie
- 39,403
- 111
- 277
- 441
-
There is not a single reason to get it. Why do you need that? – Your Common Sense Oct 23 '10 at 09:41
-
You can't think of a reason why one might want to know the name of a form? – StackOverflowNewbie Oct 23 '10 at 09:52
-
possible duplicate of [How to access the form's 'name' variable from PHP](http://stackoverflow.com/questions/846020/how-to-access-the-forms-name-variable-from-php) – Fluffeh May 08 '14 at 08:34
-
@YourCommonSense i myself do. When you have several forms pointing to the same action form to call. – webs Jan 27 '22 at 12:31
-
@webs so your question is how to tell one form from another, not "how to get the name attrubute" – Your Common Sense Jan 27 '22 at 12:39
-
@YourCommonSense yes but it is well answered here and a small test shows the answer is correct. – webs Jan 27 '22 at 17:24
2 Answers
8
Is there a way to get the value of the name attribute in the form tag? I'm using PHP and don't see it in $_POST.
No, the form's name attribute is never set to sent to the server as part of the POST data.
The easiest way around this would be adding a hidden form element <input type="hidden">
containing the name.
<form name="myform" method="post" action="" enctype="multipart/form-data">
<input type="hidden" name="frmname" value=""/>
</form>

Pekka
- 442,112
- 142
- 972
- 1,088
-
-
It doesn't work for me in any major browser. Can you show a test case where this works? Which browsers did you test this with? – Pekka May 09 '16 at 13:35