4

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.

hakre
  • 193,403
  • 52
  • 435
  • 836
StackOverflowNewbie
  • 39,403
  • 111
  • 277
  • 441

2 Answers2

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
  • No, that's incorrect. At least it's not standard behaviour. – Pekka May 09 '16 at 13:32
  • 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
1
<form name="wut">
    <input type="hidden" name="name" value="wut"/>
</form>
Robus
  • 8,067
  • 5
  • 47
  • 67