How to access the form's 'name' variable from PHP

To identify the submitted form, you can use:

  • A hidden input field.
  • The name or value of the submit button.

The name of the form is not sent to the server as part of the POST data.

You can use code as followed

<form name="myform" method="post" action="" enctype="multipart/form-data">
    <input type="hidden" name="frmname" value=""/>
</form>

You can do it like this:

<input type="text" name="myform[login]">
<input type="password" name="myform[password]">

Check the posted values

if (isset($_POST['myform'])) {
    $values = $_POST['myform'];

    // $login = $values['login'];
    // ...
}

The form name is not submitted. You should just add a hidden field to each form and call it a day.

Tags:

Php

Forms