Unit content
HTML forms and form submission
An HTML form turns user input into an HTTP request that a server can interpret.
Controls and names
Controls such as inputs, text areas and selections contribute values under their name attributes:
<form action="/orders" method="post">
<input name="customer">
<button type="submit">Create</button>
</form>
Submitting this form sends a value named customer to /orders.
Method and destination
The form's action selects the target URL and method selects the HTTP method. GET submissions normally encode values in the query string; POST submissions normally place them in the request body.
Encoding
Ordinary forms commonly use application/x-www-form-urlencoded. File uploads use multipart/form-data, which can carry file contents and ordinary fields in one request.
Only successful controls are submitted, so unchecked, disabled or unnamed controls may be absent rather than present with an empty value.
Validation
HTML attributes can help browsers detect invalid input before submission, but request data remains untrusted. The server must parse and validate the received values before using them for protected actions or persistence.
Forms connect semantic HTML to HTTP: they are the basic mechanism by which document-oriented web interfaces send user input back to the server.