Throughout the module you have submitted the booking form with method="get", and every test has left the customer's name, email address and phone number in the address bar. It was useful for learning, because you could see what was being sent, but it is unacceptable on a real site: that URL stays in the browser history, in the server logs and in any link that someone copies. In this final lesson of the module you will study in depth how the data travels: the action and method attributes, the real differences between GET and POST, the enctype encodings (and why files need a special one), the target attribute and the attributes that let a button change the destination of the submission. You will see, without programming it, what the server does with the data; you will learn about third-party form services and the privacy obligations that come with collecting personal data; and you will learn to inspect any submission with DevTools. By the end, The Blue Cup will have three complete forms: bookings, contact and newsletter.

Contents

  1. What exactly happens on submission
  2. action in depth
  3. method: GET and POST under the bonnet
  4. GET versus POST: comparison and criteria
  5. Encoding the data: enctype
  6. Where the response opens: target
  7. Buttons that change the submission: formaction, formmethod and company
  8. Controls outside the form: the form attribute
  9. What the server does with the data
  10. Third-party form services
  11. Privacy and data protection (GDPR)
  12. How to test a submission with DevTools
  13. Project: The Blue Cup's three forms

What exactly happens on submission

Let's recap the whole module in a single sequence. When the submit button is clicked, the browser:

  1. Validates the fields (unless novalidate or formnovalidate is present). If anything fails, it stops.
  2. Collects the controls with a name that are not disabled: text fields, ticked checkboxes, selected radio buttons, selected options and the clicked button if it has a name.
  3. Encodes the name=value pairs according to enctype.
  4. Builds the HTTP request with the method in method to the URL in action.
  5. Navigates: it displays the server's response in the window specified by target.

You have already mastered steps 1 and 2. This lesson focuses on steps 3, 4 and 5.

action in depth

action is the URL that receives the data. It accepts the same forms of URL as the href attribute of links (File Organisation and Paths):

Value of action Sends to Typical use
https://forms.thebluecup.example/bookings Absolute URL, on another domain An external form service
/bookings Absolute path from the root of the site itself The site's own server program
process.php Path relative to the current page Sites with PHP in the same folder
(omitted) The same URL as the page Forms that process themselves; searches that filter the page itself

A security rule with no exceptions: if the form sends personal data, the action URL (and the page containing the form) must use https://. With http://, the data travels unencrypted and anyone on the same network (a public Wi-Fi network, for example) could read it. Modern browsers warn users when a form is about to send data over an insecure connection.

method: GET and POST under the bonnet

To really understand the difference, look at the HTTP request that the browser builds. A request is a small text message with a first line (method and path), some headers (additional information) and, optionally, a body (the data).

GET: the data in the URL

With method="get", the pairs are added to the URL after a ?, as you have seen throughout the module. The request has no body:

GET /bookings?form=web-booking&name=Marta+Garc%C3%ADa&email=marta%40mail.example HTTP/1.1
Host: forms.thebluecup.example
  • The first line contains the method (GET), the path with the data and the protocol version.
  • Host indicates the domain.
  • Notice the @ in the email address encoded as %40.

POST: the data in the body

With method="post", the URL stays clean and the data travels in the body of the request, after a blank line:

POST /bookings HTTP/1.1
Host: forms.thebluecup.example
Content-Type: application/x-www-form-urlencoded
Content-Length: 66

form=web-booking&name=Marta+Garc%C3%ADa&email=marta%40mail.example
  • The path has no ? and no data.
  • Content-Type says how the data in the body is encoded (you will see this in the section on enctype).
  • Content-Length is the size of the body in bytes.
  • The body has the same name=value&… format as the GET query string. What changes is where it travels.

A very widespread misunderstanding: POST doesn't encrypt anything. The data goes in the body, out of sight, but as readable text. What protects it on the way is https. POST stops the data from ending up in the URL, the history and the logs; https stops anyone from reading it while it travels. You need both.

GET versus POST: comparison and criteria

Characteristic GET POST
Where the data goes In the URL (query string) In the body of the request
Visible in the address bar Yes No
Stays in the browser history and server logs Yes, with the URL No (only the URL, without data)
Can be bookmarked or shared as a link Yes, with the data included No
Maximum length Limited (in practice, a few thousand characters depending on browser and server) No practical limit for forms
Can send files No Yes, with multipart/form-data
When the response page is reloaded The request is repeated without warning The browser asks "Confirm Form Resubmission"
Expected idempotence Yes: repeating it should change nothing on the server No: each submission may create something new
Suitable for personal or sensitive data No Yes (always with https)

The word idempotent deserves an explanation: a request is idempotent if repeating it ten times has the same effect as making it once. Searching for "bread-making workshop" ten times changes nothing: it always gives the same results. Submitting a booking ten times could create ten bookings. That is why browsers repeat GET requests without asking (when reloading, when going back), but ask for confirmation before resending a POST.

With all this in mind, the criterion for choosing is simple:

graph TD
    A["Does the submission change something on the server? (creates a booking, signs someone up, sends a message)"] -->|Yes| P["POST"]
    A -->|No, it only queries| B["Does it include personal data, passwords or files?"]
    B -->|Yes| P
    B -->|No| C["Is it useful to be able to save or share the result as a link?"]
    C -->|Yes| G["GET"]
    C -->|No| G2["GET (the usual choice for queries)"]

Applied to The Blue Cup:

Form Method Why
News search GET It only queries; the URL …/search?q=bread-making+workshop can be saved or shared
Bookings POST It creates a booking and contains personal data
Contact POST It sends a message and contains personal data
Newsletter POST It adds an email address to a list (it changes something) and that is personal data

Encoding the data: enctype

The form's enctype attribute indicates how the data is encoded in the body of a POST request. It has three possible values:

Value When to use it
application/x-www-form-urlencoded Default. Forms without files
multipart/form-data Required if there is any input type="file"
text/plain Practically never (only for debugging; it is ambiguous)

With GET, enctype is ignored: the data always goes urlencoded in the URL.

application/x-www-form-urlencoded

This is the format you have seen throughout the module: name=value pairs joined with &, with spaces as + and special characters as %XX. Some encoding examples:

Character Encoded
space +
á / ñ %C3%A1 / %C3%B1
@ %40
& / = (inside a value) %26 / %3D
: %3A
line break %0D%0A

Look at & and =: if a customer writes "Coffee & cake" in the comments, the & is encoded as %26 so that it isn't mistaken for the separator between pairs.

It is compact and simple, but it is no good for files: an image is thousands of binary bytes which, encoded this way, would take up three times as much space.

multipart/form-data

When the form includes an input type="file", you need:

<form action="https://forms.thebluecup.example/orders" method="post" enctype="multipart/form-data">
  <p>
    <label for="name">Name</label>
    <input type="text" id="name" name="name">
  </p>
  <p>
    <label for="cake-photo">Photo of the cake you'd like</label>
    <input type="file" id="cake-photo" name="cake_photo" accept="image/*">
  </p>
  <p><button type="submit">Send order</button></p>
</form>

With this encoding, the body is divided into parts, one per field, separated by a boundary string that the browser chooses:

POST /orders HTTP/1.1
Host: forms.thebluecup.example
Content-Type: multipart/form-data; boundary=----ExampleBoundary7MA4YWxk

------ExampleBoundary7MA4YWxk
Content-Disposition: form-data; name="name"

Marta García
------ExampleBoundary7MA4YWxk
Content-Disposition: form-data; name="cake_photo"; filename="cake.jpg"
Content-Type: image/jpeg

(the bytes of the image go here, unencoded)
------ExampleBoundary7MA4YWxk--
  • Each part has its name in the Content-Disposition header.
  • The text goes unencoded (Marta García, with its accent).
  • The file part adds its original name (filename) and its type (Content-Type: image/jpeg), followed by the binary content.
  • The final boundary ends with --.

If you forget enctype="multipart/form-data" (or use GET), the file is not sent: only its name travels (cake_photo=cake.jpg). It is one of the most common mistakes with forms.

Where the response opens: target

As with links (Creating Hyperlinks), the form's target attribute decides where the server's response is displayed:

Value Effect
_self (default) In the same tab
_blank In a new tab
_parent / _top In the parent frame or the full window (with iframes)
Name of an iframe Inside that frame on the page (you will see this in Using iframes)

The normal thing is not to set target: the user submits and sees the confirmation in the same tab. Opening the response in a new tab is disorienting, for the same reasons you saw with links.

Buttons that change the submission: formaction, formmethod and company

You already know formnovalidate. It belongs to a family of attributes that go on a submit button and, only when that button is clicked, override the equivalent attribute of the form:

Button attribute Overrides
formaction action
formmethod method
formenctype enctype
formtarget target
formnovalidate novalidate

Example: a booking form with one button to submit and another to check availability at a different address:

<form action="https://forms.thebluecup.example/bookings" method="post">
  …
  <button type="submit">Send booking</button>
  <button type="submit"
          formaction="https://forms.thebluecup.example/availability"
          formmethod="get" formnovalidate>
    Check availability
  </button>
</form>
  • "Send booking" uses the form's attributes: POST to /bookings, with validation.
  • "Check availability" sends via GET to /availability, without validating (you don't need to have filled everything in just to check).

It is an alternative to the name="action" value="…" pattern from Form Elements: input, textarea and select: there, the server received the same URL and looked at which button had been clicked; here, each button sends to a different place.

Controls outside the form: the form attribute

Normally, a control belongs to the form that contains it. But sometimes the design forces you to place a control outside the form (for example, a button in another area of the page). The control's form attribute, with the form's id, associates it remotely:

<form id="newsletter-form" action="https://forms.thebluecup.example/newsletter" method="post">
  <label for="newsletter-email">Email</label>
  <input type="email" id="newsletter-email" name="email" required>
</form>

<!-- … other content … -->

<button type="submit" form="newsletter-form">Subscribe</button>

The button, even though it is outside, submits newsletter-form. It works with input, select, textarea, button, fieldset and output. Use it sparingly: a form whose controls are scattered around the page is hard to maintain and to understand, screen readers included.

What the server does with the data

You are not going to program the server, but it is worth knowing what it does, because it determines how you should design the form:

graph TD
    A["The POST /bookings request arrives"] --> B["Reads the name=value pairs"]
    B --> C{"Is the data valid? (checks everything again)"}
    C -->|No| E["Responds with the form and the errors explained"]
    C -->|Yes| D{"Is there a table or place available?"}
    D -->|No| F["Responds: no availability, suggests other times"]
    D -->|Yes| G["Saves the booking in a database"]
    G --> H["Sends a confirmation email to the customer and a notification to the café"]
    H --> I["Redirects to a confirmation page (GET)"]

Key points:

  • It reads the data by its name. That is why name values are a contract between the form and the server: if you change name="phone" to name="tel", the server will stop receiving the phone number.
  • It validates again, as you learnt in the previous lesson, and checks what HTML can't (availability, first Saturday of the month, a date that isn't in the past).
  • It always responds: with a confirmation or with the errors explained.
  • It redirects after a successful POST. This is a good practice called POST/Redirect/GET: instead of displaying the confirmation directly as the response to the POST, the server redirects to a confirmation page (for example, booking-received.html) which is loaded with GET. That way, if the user reloads, they reload the confirmation and don't resend the booking.

Third-party form services

If your site is static (just HTML, CSS and images, like The Blue Cup in this course), you don't have a program on the server to process the forms. You have three options:

Option How it works Advantages Drawbacks
Programming the server Your own program (PHP, Python, Node.js…) on your hosting Full control of the data Requires programming skills and maintenance
Third-party form service The action points to the URL the service gives you; it receives the data and forwards it to you by email or stores it in a dashboard No programming; many include spam protection Your customers' data passes through an external company; cost; dependency
Hosting features Some static site hosting services detect forms and process them Integrated Tied to that provider
mailto: in action Opens the user's email program None to speak of Doesn't work if the user has no email program set up; unreliable. Avoid it

If you choose a third-party service, the change in HTML is minimal: only the action changes (and sometimes a hidden field specified by the service is added). Before choosing one, check:

  • Where it stores the data (in which country) and for how long.
  • Whether it offers a data processing agreement (European law requires one when another company processes personal data on your behalf).
  • How it protects itself against spam: techniques such as a hidden trap field (honeypot), which humans don't see and bots fill in, or verification challenges.
  • What happens to the data if you stop paying or the service shuts down.

Privacy and data protection (GDPR)

The booking form collects personal data: name, email address, phone number and, perhaps, information about allergies in the comments (which is health data, given special protection). In the European Union, the General Data Protection Regulation (GDPR), supplemented in Spain by Organic Law 3/2018 (LOPDGDD, the Spanish data protection act), requires whoever collects that data to meet a series of requirements. From an HTML point of view, they affect three things:

  1. Informing people in the form itself

Next to the form there must be some basic information (the so-called "first layer") and a link to the full privacy policy. In Spain it is usually structured like this:

Heading What it explains
Controller Who processes the data and how to contact them
Purpose What it is used for (managing the booking)
Legal basis What the processing is based on (the customer's request, their consent…)
Recipients Who it is disclosed to (for example, the form service)
Rights That users can access, rectify and erase their data, etc., and how
Further information A link to the full privacy policy

  1. Asking for consent properly when it is needed

  • An unticked checkbox that users tick themselves. A pre-ticked checkbox is not valid consent.
  • One consent per purpose: accepting the booking cannot imply accepting marketing. If you wanted to offer the newsletter from the booking form, it would be another checkbox, optional and independent.
  • The checkbox text must say clearly what is being accepted.

  1. Asking only for what is necessary

The principle of data minimisation says that you should only collect the data you need for the purpose. Is the phone number needed to make a booking? The Blue Cup has decided that it is, to warn of any problems on the day; that justification must appear in the purpose. Is the date of birth needed? No, so it isn't requested.

Important notice: the legal texts in this lesson and in the project are teaching examples with fictitious data, not legal advice. The appropriate legal basis, the exact wording of the information, whether or not a checkbox is needed, the retention periods or the processing of health data depend on each case. Before publishing a real form that collects personal data, have the texts and the processing reviewed by a professional (a specialist lawyer or a data protection officer). You will find official guides on the website of the Spanish Data Protection Agency (AEPD).

How to test a submission with DevTools

With POST, the data no longer appears in the URL. To see it, use the Network tab in DevTools. It works even with the fictitious action, because the browser logs the request it tried to make.

In Chrome or Edge:

  1. Open the form page with Live Server and open DevTools (F12).
  2. Go to the Network tab and tick Preserve log. Without this option, the list is cleared when the browser navigates to the response and you would lose the request.
  3. Optionally, filter by Doc to see only navigations.
  4. Fill in the form and submit it.
  5. A request called bookings will appear. With the fictitious address, its status will be (failed) or an error such as net::ERR_NAME_NOT_RESOLVED: the domain doesn't exist. This is expected.
  6. Click on it:
    • In Headers you will see the destination URL, the Request Method (POST) and, in the request headers, Content-Type: application/x-www-form-urlencoded.
    • In Payload you will see the Form Data, pair by pair. With view source you will see the exact encoded string, with its + and %XX.
  7. With GET, the same tab shows them as Query String Parameters.

Firefox is very similar: the Network tab, the Persist Logs option (in the cog menu), and the data in the request's Request tab.

graph LR
    A["F12 > Network"] --> B["Preserve log"]
    B --> C["Submit the form"]
    C --> D["Click on the request"]
    D --> E["Headers: method and Content-Type"]
    D --> F["Payload: the name=value pairs"]

This technique will always come in handy, with real servers too: it is the way to check what a form really sends when something "doesn't arrive".

Project: The Blue Cup's three forms

  1. The privacy policy page

The forms are going to link to a privacy policy, so create it first. Create privacy.html in the root of the project, with the same structure as the other pages (skeleton, logo and menu):

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Privacy policy | The Blue Cup</title>
  </head>
  <body>
    <!-- Here, the shared logo and menu, as on the other pages -->

    <h1>Privacy policy</h1>
    <p><strong>Text pending.</strong> This page is a placeholder in a learning project with fictitious data. Before the site is published, the full privacy policy must be drafted or reviewed by a data protection professional.</p>
    <p>For any enquiry about your data, write to us at <a href="mailto:[email protected]">[email protected]</a>.</p>
  </body>
</html>

Don't add it to the main menu: legal policies are usually linked from the footer, which you will build in Module 6.

  1. The booking form, final version for the module

In bookings.html, the form switches to POST and adds the basic data protection information. This is the complete version:

    <h1>Book your table</h1>
    <p>Book a table for breakfast, the lunch menu or afternoon tea, or a place on our bread-making workshop on the first Saturday of every month. We will confirm your booking by email.</p>
    <p>Fields marked with * are required.</p>

    <form action="https://forms.thebluecup.example/bookings" method="post">
      <input type="hidden" name="form" value="web-booking">

      <fieldset>
        <legend>Your details</legend>
        <p>
          <label for="name">Name *</label>
          <input type="text" id="name" name="name" required minlength="2" maxlength="60" autocomplete="name">
        </p>
        <p>
          <label for="email">Email *</label>
          <input type="email" id="email" name="email" required maxlength="100" autocomplete="email">
        </p>
        <p>
          <label for="phone">Phone *</label>
          <input type="tel" id="phone" name="phone" required
                 pattern="(\+34 ?)?[6-9]( ?[0-9]){8}"
                 title="9-digit Spanish phone number, with or without +34"
                 placeholder="600 000 000" autocomplete="tel">
          <br><small>9-digit Spanish phone number, with or without +34 and with or without spaces.</small>
        </p>
      </fieldset>

      <fieldset>
        <legend>Your booking</legend>
        <fieldset>
          <legend>What would you like to book? *</legend>
          <input type="radio" id="type-table" name="type" value="table" checked required>
          <label for="type-table">A table</label>
          <input type="radio" id="type-workshop" name="type" value="workshop" required>
          <label for="type-workshop">A place on the bread-making workshop (first Saturday of every month, 10:00–13:00)</label>
        </fieldset>
        <p>
          <!-- Update min and max periodically: HTML cannot work out "today" -->
          <label for="date">Date *</label>
          <input type="date" id="date" name="date" required min="2026-12-01" max="2027-03-31">
        </p>
        <p>
          <label for="time">Time *</label>
          <input type="time" id="time" name="time" required min="08:00" max="19:00" step="1800">
          <br><small>From 8:00 to 19:00, on the hour or half past.</small>
        </p>
        <p>
          <label for="guests">Number of guests *</label>
          <input type="number" id="guests" name="guests" required min="1" max="12" step="1" value="2">
          <br><small>Up to 12 people. For larger groups, call us on <a href="tel:+34900000000">+34&nbsp;900&nbsp;000&nbsp;000</a>.</small>
        </p>
        <p>
          <label for="occasion">Are you celebrating anything? (optional)</label>
          <input type="text" id="occasion" name="occasion" list="occasions" maxlength="40">
          <datalist id="occasions">
            <option value="Birthday">
            <option value="Anniversary">
            <option value="Farewell party">
            <option value="Work meeting">
            <option value="Christening or first communion">
          </datalist>
        </p>
      </fieldset>

      <fieldset>
        <legend>Preferences</legend>
        <fieldset>
          <legend>Area (table bookings only)</legend>
          <input type="radio" id="area-indoor" name="area" value="indoor" checked>
          <label for="area-indoor">Indoors</label>
          <input type="radio" id="area-terrace" name="area" value="terrace">
          <label for="area-terrace">Terrace</label>
        </fieldset>
        <p>
          <label for="comments">Comments (allergies, highchairs…)</label><br>
          <textarea id="comments" name="comments" rows="4" cols="40" maxlength="500"></textarea>
          <br><small>500 characters maximum. If you tell us about any allergies or intolerances, we will only use that information to prepare for your visit.</small>
        </p>
      </fieldset>

      <p><small><strong>Basic data protection information.</strong>
        Controller: The Blue Cup, 12 Example Street, Fictional Town (<a href="mailto:[email protected]">[email protected]</a>).
        Purpose: to manage your booking and let you know about any issue affecting it.
        Legal basis: managing the booking you have requested from us.
        Recipients: the provider that manages our forms, as a data processor; your data will not be disclosed to anyone else unless required by law.
        Rights: you can access, rectify and erase your data, among other rights, by writing to us.
        Further information in our <a href="privacy.html">privacy policy</a>.</small></p>

      <p>
        <input type="checkbox" id="privacy" name="privacy" value="accept" required>
        <label for="privacy">I have read the data protection information *</label>
      </p>

      <p>
        <button type="submit">Send booking</button>
      </p>
    </form>

What has changed compared with the previous lesson:

  • method="post", and the comment announcing it as temporary has gone. The URL will no longer show personal data.
  • The opening paragraph also mentions the bread-making workshop, which the form now lets you book.
  • The basic data protection information appears just before the checkbox, in small, with a link to the full policy. The link is outside the label, as you learnt in Labels and Grouping: label, fieldset, legend and datalist.
  • The checkbox text says exactly what is being confirmed: that the information has been read. (Here the basis for processing is the booking requested by the customer; which text and which checkbox are appropriate in a real case is precisely what a professional should review.)
  • The comments field gives notice of how allergy data, which is health data, will be used.
  • No enctype is needed: the form has no files.

  1. A contact form in contact.html

At the end of contact.html, after the address, phone number and email address, add a simple form. Reuse the select of reasons you wrote in an exercise in Form Elements: input, textarea and select:

    <h2>Write to us</h2>
    <p>Do you have a question, an order or a suggestion? We will reply within two working days. Fields marked with * are required.</p>

    <form action="https://forms.thebluecup.example/contact" method="post">
      <input type="hidden" name="form" value="web-contact">
      <p>
        <label for="name">Name *</label>
        <input type="text" id="name" name="name" required minlength="2" maxlength="60" autocomplete="name">
      </p>
      <p>
        <label for="email">Email *</label>
        <input type="email" id="email" name="email" required maxlength="100" autocomplete="email">
      </p>
      <p>
        <label for="reason">Reason for your message *</label>
        <select id="reason" name="reason" required>
          <option value="">Choose a reason</option>
          <optgroup label="Bookings">
            <option value="check-booking">Check a booking</option>
            <option value="cancel-booking">Cancel a booking</option>
          </optgroup>
          <optgroup label="Other">
            <option value="orders">Cake and pastry orders</option>
            <option value="jobs">Work with us</option>
            <option value="other">Another reason</option>
          </optgroup>
        </select>
      </p>
      <p>
        <label for="message">Message *</label><br>
        <textarea id="message" name="message" rows="6" cols="40" required minlength="10" maxlength="2000"></textarea>
      </p>

      <p><small><strong>Basic data protection information.</strong>
        Controller: The Blue Cup. Purpose: to reply to your message. Legal basis: your request.
        Recipients: the provider that manages our forms, as a data processor.
        Rights: access, rectification, erasure and others, by writing to <a href="mailto:[email protected]">[email protected]</a>.
        Further information in our <a href="privacy.html">privacy policy</a>.</small></p>
      <p>
        <input type="checkbox" id="privacy" name="privacy" value="accept" required>
        <label for="privacy">I have read the data protection information *</label>
      </p>

      <p><button type="submit">Send message</button></p>
    </form>
  • POST: it sends a message containing personal data.
  • A required select with an empty first option: the user must choose a reason.
  • reason helps route the message to the right person without asking for more data.
  • The hidden field changes to web-contact, even though the action is already different: it costs nothing and makes things easier to organise if the form service groups everything together.
  • There is no phone number: to reply to a message, the email address is enough (minimisation).
  • It is important to keep the page's mailto: and tel: links: some people prefer to write or call directly.

  1. Newsletter sign-up in news.html

At the end of news.html (the search box stays at the top, with GET), add:

    <h2>Monthly newsletter</h2>
    <p>Once a month: what's new on the menu, dates for the bread-making workshop and the odd recipe. You can unsubscribe whenever you like using the link included in every newsletter.</p>

    <form action="https://forms.thebluecup.example/newsletter" method="post">
      <input type="hidden" name="form" value="newsletter">
      <p>
        <label for="newsletter-email">Email</label>
        <input type="email" id="newsletter-email" name="email" required maxlength="100" autocomplete="email">
      </p>
      <p>
        <input type="checkbox" id="newsletter-consent" name="consent" value="yes" required>
        <label for="newsletter-consent">I want to receive The Blue Cup's monthly newsletter by email</label>
      </p>
      <p><small>Controller: The Blue Cup. Purpose: to send you the newsletter. Legal basis: your consent, which you can withdraw at any time. Recipients: the newsletter delivery provider, as a data processor. Rights and further information in our <a href="privacy.html">privacy policy</a>.</small></p>
      <p><button type="submit">Subscribe</button></p>
    </form>
  • POST, even though there is only one field: the submission adds an email address to a list (it changes something on the server) and the email address is personal data that shouldn't end up in URLs or histories. Compare it with the search box on the same page: GET, because it only queries.
  • Here the basis is consent, so the unticked checkbox is essential, and its text describes exactly what is being accepted.
  • The id values carry the newsletter- prefix so as not to clash with other id values on the page (search). The name values don't need a prefix: they belong to another form.
  • It is a form independent of the search box: one after the other, never nested.

  1. Check the three submissions

For each form, with the Network tab open and Preserve log turned on:

  1. Fill it in correctly and submit it.
  2. Check that the URL in the address bar does not contain any data.
  3. In the request, check that the method is POST and that all the expected name values appear under Payload.
  4. Also submit a search in news.html and observe the difference: the GET method and the data in the URL.

Common Mistakes and Tips

  • Personal data or passwords with GET: they stay in the URL, the history and the logs. Use POST.
  • Believing that POST is secure in itself: without https, the data travels in readable form.
  • Forgetting enctype="multipart/form-data" with files: only the file name is sent.
  • Using POST for searches: it prevents results from being saved and shared, and the browser will ask for confirmation on reload.
  • Changing a name without telling whoever programs the server: the data stops arriving.
  • action="mailto:…": unreliable; use a server or a form service.
  • Forgetting "Preserve log" when inspecting in the Network tab: the request disappears when the browser navigates.
  • Pre-ticked consent checkboxes or ones that mix purposes: they are not valid. One unticked checkbox per purpose.
  • Asking for data "just in case": every extra data item is a risk and an obligation. Ask only for what is necessary.
  • Publishing legal texts copied from another site or from a course: every processing operation is different. Have them reviewed by a professional.
  • Tip: keep a table listing each form on the site, its action, its method and its name values. It is the documentation that whoever programs or configures the server will need.

Exercises

Exercise 1. Decide on the method (GET or POST) for each form and justify it: a) gallery filter by product type; b) cancelling a booking with its code; c) signing in to the staff dashboard; d) the site's language selector; e) sending a CV in PDF.

Exercise 2. Write the form start tag and the file field for The Blue Cup's "Work with us" form, which sends the name, email address and CV (PDF or Word, a single file) to https://forms.thebluecup.example/jobs.

Exercise 3. In the contact form, add a second button, "Save as draft", that sends to https://forms.thebluecup.example/drafts without validating, while the main button carries on working as before. Then explain what you would see in the Network tab when each button is clicked.

Solutions

Solution 1.

Form Method Justification
a) Gallery filter GET It only queries; the filtered URL can be shared ("take a look at the pastries")
b) Booking cancellation POST It changes something on the server (it cancels the booking); it must not be repeated on reload
c) Signing in POST It sends a password: never in the URL (and always with https)
d) Language selector GET It only changes what is displayed; the URL in another language can be shared
e) CV POST It sends a file (it needs multipart/form-data) and personal data

Solution 2.

<form action="https://forms.thebluecup.example/jobs" method="post" enctype="multipart/form-data">
  …
  <p>
    <label for="cv">CV (PDF or Word) *</label>
    <input type="file" id="cv" name="cv" required
           accept=".pdf,.doc,.docx,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document">
  </p>
  …
</form>
  • method="post" and enctype="multipart/form-data", both essential for sending the file.
  • accept combines extensions and types so that the picker offers PDF and Word files (.pdf,.doc,.docx would be enough); remember that it is only a filter: the server must check the file.
  • No multiple: a single file.
  • A CV contains a great deal of personal data: this form would also need its basic data protection information, reviewed by a professional.

Solution 3.

      <p>
        <button type="submit">Send message</button>
        <button type="submit"
                formaction="https://forms.thebluecup.example/drafts"
                formnovalidate>
          Save as draft
        </button>
      </p>
  • formmethod isn't needed: it inherits the form's post.
  • formnovalidate allows saving even if required fields are missing.

In the Network tab:

  • "Send message": if anything is missing, no request appears (validation stops it). If everything is correct, a POST request to /contact with all the pairs under Payload.
  • "Save as draft": a POST request always appears, but to /drafts, with the fields as they are, including empty ones (message=). The privacy checkbox will only appear if it is ticked.

Conclusion

With this lesson you complete the Forms in HTML module. You have learnt how a form really travels: action decides the destination and must use https; GET puts the data in the URL and is for queries that can be shared, while POST carries it in the body and is the method for anything that changes something or contains personal data; enctype chooses the encoding, and multipart/form-data is required for sending files; target, the formaction family of attributes and the form attribute fine-tune where and how the form is submitted. You have seen what the server does with the data and why it must validate it again, the alternatives for a static site, the basic data protection obligations (inform, obtain consent without pre-ticked checkboxes, ask only for what is necessary and have the texts reviewed by a professional) and how to inspect any submission in the Network tab. Over the course of the module, bookings.html has gone from a "Very soon…" to a complete form, organised, validated and sent via POST; contact.html has its message form and news.html has a search box and a newsletter sign-up. The site now works, but if you look closely at its code you will see that it is full of generic div elements and that the menu is still a loose ul with a comment promising "in Module 6 it will go inside a nav element". The time has come to keep that promise: in the next module, HTML5 Semantic Elements, you will start with the lesson Introduction to Semantic HTML and learn to give each part of the page the element that describes its meaning.

HTML Course

Module 1: Introduction to HTML

Module 2: Text Formatting in HTML

Module 3: Links and Media in HTML

Module 4: Tables in HTML

Module 5: Forms in HTML

Module 6: HTML5 Semantic Elements

Module 7: Advanced HTML Techniques

Module 8: Integrating HTML and CSS

Module 9: Responsive Web Design

Module 10: Best Practices and Accessibility

Module 11: Project: Building a Complete Website

© Copyright 2026. All rights reserved