All subjects · Information Technology · WIT12 3 hour practical exam on web development with HTML, CSS and JavaScript

How forms send data, and HTML form validation

Edexcel IAL Information Technology · WIT12 3 hour practical exam on web development with HTML, CSS and JavaScript

When a form is submitted, the browser checks the data and sends it to a server. You need to know how the data travels (GET and POST) and the HTML validation attributes (spec 7.3.4).

Practise this in the app: instant marking and a fix for every mistake. Free, no email needed to start.

Practise this lesson

From browser to server

When the user submits a form:

1. The browser checks any HTML validation rules. If one fails, it shows a message and does not send the form.

2. It collects each control's name and value as name=value pairs.

3. It sends them to the URL in the action attribute, using the method.

4. A program on the server (for example in PHP) processes the data and sends back a response page.

For example, <form action="search.php" method="get"> sends the data to search.php using GET.

GET and POST

method="get"method="post"
Where the data goesAdded to the URL as a query string: search.php?town=leeds&type=adultSent in the body of the HTTP request, not in the URL
VisibilityVisible in the address bar, history, bookmarks and server logsNot visible in the URL (but still readable unless HTTPS encrypts it)
SizeLimited by the maximum URL lengthNo practical limit: suits long text and file uploads
Use forSearches and filters that can be bookmarked or sharedPasswords, personal data, payments and anything that changes data on the server

The default method is get. Examiners want the specific difference, not just 'POST is more secure'.

HTML validation attributes

<input type="text" name="fname" required minlength="2" maxlength="30">
<input type="number" name="age" min="16" max="99" step="1">
<input type="text" name="postcode" pattern="[A-Z]{2}[0-9]{1,2} [0-9][A-Z]{2}" title="For example AB12 3CD">
<input type="email" name="email" placeholder="name@example.com">

HTML validation improves the user experience, but users can bypass it, so servers must check the data again. JavaScript validation (Topic 9) gives custom messages and more complex rules.

Worked example

A search form uses method="get" and has one box named q. The user searches for 'tennis' and submits to results.html. What URL does the browser request?

  1. GET adds the data to the URL after a question mark.
  2. The pair is the control's name, an equals sign and its value.

Answer: results.html?q=tennis

Key idea: Submitting sends name=value pairs to the action URL. GET puts them in the URL (visible, length-limited, bookmarkable); POST puts them in the request body (not in the URL, any size). required, minlength, maxlength, min, max, step, type and pattern give built-in validation.

Check yourself

  1. A form `<form action="find.html" method="get">` has one input named town. The user types York and submits. What URL is requested? Type it exactly.
    Show answer

    find.html?town=York. GET appends ?name=value to the action URL.

  2. Explain one difference between the GET and POST methods of sending form data.
    Show answer

    GET adds the data to the URL so it can be seen in the address bar, while POST sends it in the body of the request so it is not shown in the URL.. Valid differences: GET data is in the URL (visible, saved in history, bookmarkable, length-limited); POST data is in the request body (not in the URL, no practical size limit).

  3. Which attribute is a presence check?
    • required
    • placeholder
    • maxlength
    • pattern
    Show answer

    required. required stops the form being submitted with the field empty.

  4. Which input accepts only whole numbers from 1 to 5?
    • `<input type="text" minlength="1" maxlength="5">`
    • `<input type="number" placeholder="1 to 5">`
    • `<input type="range" value="5">`
    • `<input type="number" min="1" max="5" step="1">`
    Show answer

    `<input type="number" min="1" max="5" step="1">`. min and max give a range check and step="1" allows whole numbers only. maxlength counts characters, and placeholder does not validate.

  5. Why is placeholder not a replacement for a label?
    • It stops the form submitting
    • It disappears when the user types and is not reliably announced as the field's name
    • It only works on number inputs
    • It changes the data sent to the server
    Show answer

    It disappears when the user types and is not reliably announced as the field's name. Placeholder text vanishes on typing and has poor contrast, so a visible label is still needed.

  6. Why must data checked by HTML validation still be checked on the server?
    • HTML validation only runs on the server
    • Browsers delete validated data
    • Servers cannot read unvalidated data
    • Users can bypass browser validation, for example by turning it off or sending requests directly
    Show answer

    Users can bypass browser validation, for example by turning it off or sending requests directly. Client-side checks help users but can be bypassed, so the server checks again.

  7. Which method should a login form use?
    • get, so the login page can be bookmarked
    • post, so the password is not shown in the URL, history or server logs
    • get, because it is faster for small amounts of data
    • Either, because each method shows the data in the URL
    Show answer

    post, so the password is not shown in the URL, history or server logs. POST keeps the password out of the URL; HTTPS is still needed to encrypt it.

Practise with instant feedback

Sources

Last updated 8 November 2026. Spotted a mistake? Tell us.