Lesson 40 of 51 · Module 6, lesson 6 of 6 · 4 min
Where form data goes
Understand action, GET and POST, what really keeps data safe, and how autocomplete helps people.
What you'll learn
- What
actionandmethoddo- The real difference between GET and POST — and what actually keeps data safe
- How
autocompletehelps people fill in forms faster
Why this matters
Until now, your forms sent their data back to the same page, so that you could see it in the address bar. A real form sends its data to a program on a server, which saves it, emails it, or searches with it. You will write such programs later; here you learn the HTML side.
action: where the data goes
action is the address that receives the data:
<form action="https://example.com/newsletter" method="post">
Without action, the form goes to the page it is on — as in all the examples so far. That is why they worked from your computer.
If you set action to a path like /signup and open the page from your computer, the browser looks for a file called signup at the top of your disk and shows "file not found". That is not a bug in your form — there is no server there to receive it.
method: GET or POST
method="get" (the default) | method="post" | |
|---|---|---|
| Where the data goes | In the address: ?q=soup | Inside the request, not in the address |
| Can be bookmarked or shared | Yes | No |
| Use it for | Searches and filters | Sign-ups, messages, payments — anything that changes or saves something |
<!-- A search: GET, so the results page can be bookmarked -->
<form action="https://example.com/search" method="get">
<label for="q">Search recipes</label>
<input id="q" name="q" type="search">
<button type="submit">Search</button>
</form>
What keeps data safe
A common belief is that POST is "secure". It is not. POST data is not in the address bar, but it travels as openly as GET data. What protects data on its way is HTTPS — the https:// at the start of an address, with the padlock in the browser. Any form that sends personal information must send it to an https:// address.
autocomplete: fill in faster
The autocomplete attribute tells the browser what a field is for, so that it can offer the visitor's saved name, email or address. This helps everyone, and especially people who find typing difficult. Common values:
| Field | autocomplete value |
|---|---|
| Full name | name |
email | |
| Phone | tel |
| Street address | street-address |
| Postcode | postal-code |
| Country | country-name |
| Password when logging in | current-password |
| New password when signing up | new-password |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Delivery details</title>
</head>
<body>
<h1>Delivery details</h1>
<form>
<p>
<label for="fullname">Full name</label>
<input id="fullname" name="fullname" type="text" autocomplete="name" required>
</p>
<p>
<label for="email">Email</label>
<input id="email" name="email" type="email" autocomplete="email" required>
</p>
<p>
<label for="street">Street address</label>
<input id="street" name="street" type="text" autocomplete="street-address">
</p>
<p><button type="submit">Continue</button></p>
</form>
</body>
</html>
You may read advice to turn it off with autocomplete="off" on login forms. Do not: browsers ignore it for passwords anyway, and it stops password managers from helping people use strong passwords.
Sending files
A form that uploads a file needs method="post", the attribute enctype="multipart/form-data", and an <input type="file">. You will use it when you work with a server.
Try it yourself
- Select the delivery example and choose Try it.
- Submit it and read the data. Then add
method="post"to the form and submit again: the playground shows POST instead of GET. - In your own browser, open the form and click in the name box. Does the browser offer your saved name?
Common mistakes
action="/something"on a page opened from your computer. You get "file not found". Fix: leave outactionwhile learning, or use a fullhttps://address.- Believing POST protects data. Fix: send personal data only to
https://addresses. autocomplete="off"on normal fields. It slows people down. Fix: use the rightautocompletevalue instead.- GET for a form that changes something, such as a sign-up. The data ends up in bookmarks and history. Fix:
method="post".
Check yourself
- What does a form do if it has no
action? - What protects form data while it travels: POST, or HTTPS?
- Which
autocompletevalue fits a new password on a sign-up form?
Answers
- It sends the data to the same page.
- HTTPS.
new-password.
Next: that completes forms. Build a complete sign-up form in the practice exercise.
a course sign-up form
Starter code
Build it in your own folder, on your computer. ZAM students hand this project in on their dashboard, and their mentor reviews it.

