Click here to read Part 2
The following is a simple example of an HTML form: <form method="post" action="page.php">
Name: <input type="text" name="Name"><br>
City: <input type="text" name="City"><br>
<input type="submit" value="Submit">
</form>
This basic segment is placed inside an HTML page and when users browse to that page, they generally see something like this:
The user is expected to fill in values for the Name and City and submit the form. Upon submission, the data is encoded, posted back to the server and routed to 'page.php' for handling. The general transmission is something like the following:
POST /page.php HTTP/1.1
Host: www.website.com
User-Agent: Mozilla/5.0
Content-Length: 27
Content-Type: application/x-www-form-urlencoded
Name=John+Doe&City=New+York
The first paragraph is the header describing the size and MIME type of the data among other information. The second paragraph contains the submitted data in an encrypted format with the fields delimited with '&'. The handling page, 'page.php', would generally contain a script to digest the data and take some kind of an action, such as validating the data, saving them to a database, or look up and display related information based on the submitted data.
This, of course, is a simple form, but all HTML forms behave the same way at their cores. Debugging forms is a relatively straight-forward task these days. The simplest step is to have the receiving page just print out the submitted values back to make sure that the page is correctly receiving the submitted data. Sometimes, however, it might be helpful to inspect the POST data in raw format. In those cases, scripts can be written to receive the data and display them without any processing. There are also utilities available online that can be used to achieve the same task with ease.
This site also has one such tool available that users can utilize to view their form POST data in raw format. To use this tool, the 'action' parameter of the form is set to the page's URL.Tthe form is then populated and submitted and the page. Upon submission, the POST data is displayed to the user. Visit
Form Post Tester/Viewer for more information on this tool.
html,
html forms,
post,
web servers,
http headers,
headers,
httpLabels: headers, html, html forms, http, http headers, post, web servers
<
HTML Forms, Part 3>
// posted by rh
Click here to read Part 1
There are really many steps that a browser goes through to display a web page or post some data to it. For the purposes of this discussion, a simplified process consists of a request and a response. The browser makes a request to a server for a particular page, and the server returns the data to the browser in the form of a response.
There are a few types of requests a browser can issue using commands that are generally known as 'verbs'. The most widely used verb is GET. Whenever you visit a web page, your browser issues a GET command to the server along with some other parameters and the server obliges by returning the data for the particular page.
In fact you are reading this very page because your browser made a GET request to www.hashemian.com and specified this page. The server then returned this page to your browser in a raw format. Your browser then rendered it as you see now.
But what happens when you submit a form to a page? In that case the page generally contains a FORM tag like this:<form method="POST" action="some_page">
some form elements such as <INPUT> here
a submit <BUTTON> here
</form>
Notice the POST verb specified as an attribute of the form tag. When you click on the Submit button, the data you entered on the form is sent to some_page using the POST verb. The POST verb is similar to the GET verb but there are some additional data. The browser contacts some_page, issues the POST command, it also specifies Content-Length and Content-Type.
Content-Length is the character length of the data that you have submitted to the page, while Content-Type specifies the format of the data. The data format, known as MIME type, is generally specified as application/x-www-form-urlencoded. That signals to the server that data was encoded in a specific format so the server can figure out how to decrypt and use the data. We'll delve into more details on POST in part 3.
html,forms,get,post,urlLabels: post, programming, url, web
<
HTML Forms, Part 2>
// posted by rh