What is a input name attribute?

The name attribute of a form field is the label its value is sent under: a field without a name is left out of the submission.

When a form is submitted, the browser sends pairs of name and value. The name comes from the field's name attribute. The id, the placeholder and the label text are not sent at all. A field with no name is skipped, as are disabled fields and checkboxes that are not checked.

A missing name is one of the most common form bugs. The form submits, the thank-you page appears, and the submission arrives with that field missing, or with nothing in it at all. Names also become the column headings and email labels wherever the data ends up, so pick clear ones such as email and message.

FormTango stores each field under its name, and answers with a 400 error if a form has no named fields. Names that start with an underscore are treated as instructions and not data. If a field is named email, replying to the notification email replies to the visitor.

html
<!-- Sent as email=... -->
<input type="email" name="email">

<!-- Not sent: no name -->
<input type="email" id="email" placeholder="Email">

Related