Forms

8TML > Guides

This guide builds a guestbook: a form on an 8TML page, and what the server receives.

The form

:::form post guestbook.php
## Sign the guestbook
? text   name  max=20       Your name
? area   msg   rows=3 max=200 Message
? check  news  value=yes    Send me news
? submit send  value=ok     Sign it
:::

Preview: Commodore 64, 40 columns

                                            
Sign the guestbook
Your name [____________________]
Message
[______________________________________]
[______________________________________]
[______________________________________]
[ ] Send me news
< Sign it >
  • :::form post guestbook.php opens the form: the method (get or post) and the address it is sent to, relative to the page. A line with just ::: closes it.
  • Lines starting with ? are fields: type, name, options, label.
  • Every other line inside the form is normal 8TML, like the heading here.

The field types are text, password, area, check, radio, select, hidden, submit and reset; each has its own page under Forms.

What the server receives

When the reader presses Sign it, the client sends the fields in page order, encoded the way HTML forms are (application/x-www-form-urlencoded):

POST /guestbook.php HTTP/1.0
Host: example.com
Content-Type: application/x-www-form-urlencoded
Content-Length: 39

name=Anna&msg=Hello+from+my+C64&send=ok

The checkbox isn’t sent because it wasn’t ticked; the pressed button sends its own name and value. With get instead of post, the same data is appended to the address after a ?.

The answer

The server answers with a new page, and that page should be 8TML too:

---
8tml: 1
title: Thank you
---

# Thank you, Anna!

Your message is in the [guestbook](guestbook.8tml).

A client never sends a POST form again by itself: going back or reloading doesn’t sign the guestbook twice.

Things to keep in mind

  • There are no cookies in 8TML 1. To keep a reader logged in from page to page, the server puts a token into a hidden field or into the links of the pages it sends.
  • Plain HTTP sends everything readable, passwords included. Don’t ask for passwords that protect anything valuable.
  • Every client supports at least 16 fields per form, 80 characters per text field and 255 per text area. Stay within these limits.