Summary
In this chapter, I described the different ways that applications can receive form data, make it safe to handle, and check that it is the data that the application requires:
- Form data can be sent using
GET
andPOST
requests, which affects how the data is encoded. - Caution is required when sending data with
GET
requests because the results may be cached. - Different encodings are available for forms sent over
POST
requests, including an encoding that allows file data to be sent. - Form data should be sanitized before it is included in HTML output or used in any operation where the values may be evaluated as trusted content.
- Form data should be validated before it is used to ensure the values sent by the user can be safely used by the application.
- Validation can be done by the server or the client. Client-side validation does not replace server-side validation.
In the next chapter, I will explain how databases are used in Node.js...