Can somebody explain HTML forms to me like I'm an actual retard?

Not the styling of the form , or the validation (although that has my head twisted too)

What's this action/method carry on ?

Where does the form data go?

How does it get there?

#AskNostr

Reply to this note

Please Login to reply.

Discussion

What do you already know?

So, to keep it short: HTML forms consist of the

tag, which specifies where and how the data is sent, and of one or more tags, which define what data is sent.

In the form tag, the "action" attribute tells the address/URL, where the data is sent to and the "method" attribute tells where in the HTTP request the data is added.

If method is "get", then the data is added to the so-called "query" of the URL.

For example: If you have an input item with name "foo" and value "bar", then the URL will be something like https://your.domain.com/the.action.address?foo=bar

If the action is "post", then the data is added to the so-called "body" of the HTTP request. Essentially, the request body can take much more data than the query, so most forms work with a "post" method.

Thanks , that's a good description. I think I need to understand http a bit more.

w3schools html5 🤙🙏

I want someone to put the information across colloquially.

```

```

Okay, so action is often just the URL that you want to send the data in your form to.

Method is about how you want that data to be sent. You have 2 options:

1. POST: This sends the data to the destination in a way that the server can read and process it silently. You also have the luxury of being able to send unlimited information, so you can include file uploads too.

2. GET: This appends your data onto the URL and just visits it:

```

/destination?name=Bob&age=30

```

There is a limit to the size of data that can be sent this way, but it has some benefits:

1. the user can see everything that is being sent by looking at the browser URL

2. If you're building a web app with no backend and database, then you might be handling everything in browser with some JavaScript. If the data is in the URL, then the web app can read this data and use it. It can't read POST data.

Typically, you send via POST if:

1. You are sending a file

2. You are sending data to be actioned, like a command with details (send an email with contents=.....)

3. You want the data to be stored in the database

Typically you send a GET if:

1. You are just querying (search)

2. You are applying a filter (ages=20-30)

3. You are indicating an ID (/profile?id=10

3. You are building a web app with a dumb server so the webpage needs to read the data.

The inputs in the form indicate what data is put into the POST or GET data:

```

```