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.

6
  • There is not a single reason to get it. Why do you need that? Commented Oct 23, 2010 at 9:41
  • You can't think of a reason why one might want to know the name of a form? Commented Oct 23, 2010 at 9:52
  • possible duplicate of How to access the form's 'name' variable from PHP Commented May 8, 2014 at 8:34
  • @YourCommonSense i myself do. When you have several forms pointing to the same action form to call. Commented Jan 27, 2022 at 12:31
  • @webs so your question is how to tell one form from another, not "how to get the name attrubute" Commented Jan 27, 2022 at 12:39

2 Answers 2

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>
Sign up to request clarification or add additional context in comments.

2 Comments

No, that's incorrect. At least it's not standard behaviour.
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?
1
<form name="wut">
    <input type="hidden" name="name" value="wut"/>
</form>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.