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
  • 184,866
  • 48
  • 414
  • 792
StackOverflowNewbie
  • 37,253
  • 107
  • 262
  • 431

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
  • 431,103
  • 135
  • 960
  • 1,075
  • 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
  • 7,647
  • 5
  • 45
  • 65