Nav: [Workbook](../workbook.md) :: [Basic Concepts](../basics/basics.md) :: [Handling Requests: Header Fields](./headers.md) # Handling Requests: Form/Query Data ##### Table of Contents - [Reading Form Data](#read) - [Query Parameters](#query) - [Form Parameters](#form_parameters) - [Uniform Read](#uniform) - [Reading Parameters and Values](#reading_pv) - [How to read all parameters names](#all_names) - [How to read single values](#single_values) - [How to read multiple values](#multiple_values) - [How to read table values](#table_values) - [Reading raw data](#raw_data) - [Upload Files](#upload) - [Examples](#examples) An HTML Form can handle GET and POST requests. When we use a form with method GET, the data is attached at the end of the url for example: >http://wwww.example.com?key1=value1&...keyn=valuen If we use the method POST, the data is sent to the server in a different line. Extracting form data from the server side is one of the most tedious parts. If you do it by hand, you will need to parse the input, you'll have to URL-decode the value. Here we will show you how to read input submitted by a user using a Form (GET and POST). * How to handle missing values: * client side validattion, server side validations, set default if it's a valid option. * How to populate Eiffel objects from the request data. ## Reading Form Data EWF [WSF_REQUEST]() class, provides features to handling this form parsing automatically. ### Query Parameters WSF_REQUEST.query_parameters: ITERABLE [WSF_VALUE] -- All query parameters WSF_REQUEST.query_parameter (a_name: READABLE_STRING_GENERAL): detachable WSF_VALUE -- Query parameter for name `a_name'. ### Form Parameters WSF_REQUEST.form_parameters: ITERABLE [WSF_VALUE] -- All form parameters sent by a POST WSF_REQUEST.form_parameter (a_name: READABLE_STRING_GENERAL): detachable WSF_VALUE -- Field for name `a_name'. The values supplied to form_parameter and query_parameter are case sensitive. ### Read Data The previous features, let you read the data one way for GET request and a different way for POST request. WSF_REQUEST provide a feature to read all the data in a uniform way. WSF_REQUEST.item (a_name: READABLE_STRING_GENERAL): detachable WSF_VALUE -- Variable named `a_name' from any of the variables container -- and following a specific order: form_, query_ and path_ parameters So, you use **WSF_REQUEST.item** feature exactly the same way for GET and POST request. >Note: if a query parameter has the same name as a form paramenter req.item will retrieve the form paramenter. Remember the precedence: form > query > path ## Reading Parameters and Values Suppose we have the following HTML5 form using Method POST. This HTML5 form has client side form validation using the new HTML5 attribute, you can do the same using Javascript. So in this case if the user does not fill the fields as expected the form will not be submitted to the server. >Note: You want to validate on the server side because you can protect against the malicious user, who can easily bypass your JavaScript and submit dangerous input to the server. ```