The sending of data to a CGI script is done via an HTML form.
HTML forms are created using the <FORM> tag, containing buttons, fields, lists and check boxes, labeled with names that will involve values, user input functions and a submit button on the form that will send all the information collected to the specified script as the Action attribute of the FORM tag (via the GET or POST method). Each element of the form must have a unique name, which combined to its value will create a pair of this type:
The name/value sets are separated by ampersands ("&" ). Thus, when sending a form creates a string of the form:
This string will be different depending on whether the method used to submit the form is GET or POST.
GET and POST methods
The GET method sends the form elements through the URL of the script. It will add the name\value pairs to the URL of the script, separating each element using a question mark, thus giving a URL like this:
However, the length of the URL string is limited to 255 characters, information beyond this limit will be permanently lost. In addition, it creates a overloaded URL in the address bar of a browser and can reveal sensitive information like a password ...etc
Thus, the POST method is a good alternative to the GET method. This method encodes the information in the same way as the GET method (URL encoding and name/value pairs), but it sends the data in a field called the "body of the request". In this way the amount of data sent is not limited!
Published by deri58
Latest update on April 7, 2013 at 04:45 AM by deri58.