reading-notes

Sending Form Data

Source: Sending form data

Reference: Forms in HTML5

Elements

<form> defines how data will be sent

Attributes

action where data is sent (with no action, its sent to the same page)

<!--absolute url -->
<form action="https://example.com">
<!--relative url -->
<form action="/somewhere_else">

method how data is sent (GET versus POST)

Viewing HTTP Requests

In Chrome:

  1. Open the developer tools.
  2. Select “Network”
  3. Select “All”
  4. Select “foo.com” in the “Name” tab
  5. Select “Headers”

Sending Files

Extra steps:

  1. method="post"
  2. enctype ="multipart/form-data"
  3. Include 1+ <input type="file">
<form method="post" action="https://www.foo.com" enctype="multipart/form-data">
  <div>
    <label for="file">Choose a file</label>
    <input type="file" id="file" name="myFile">
  </div>
  <div>
    <button>Send the file</button>
  </div>
</form>

Security

All data that comes to your server must be checked and sanitized. Always. No exception.