Software, your way.
burger menu icon
WillMaster

WillMaster > LibraryManaging Website Forms

FREE! Coding tips, tricks, and treasures.

Possibilities weekly ezine

Get the weekly email website developers read:

 

Your email address

name@example.com
YES! Send Possibilities every week!

How the Browser Formats Form Submissions

When a web page form is submitted, the form data is sent somewhere. Generally, it's submitted to software on the server to handle the data.

For forms with data composed of more than a couple hundred characters, the submission method is almost always method="POST".

(The reason is that the number of characters to send method="GET" is limited to 257 or 1024 characters depending on the browser and on the server where the data is sent to.)

To submit the data method="POST", the form encodes and/or formats the data in one of three ways before sending it to the form-handling software on the server. The three ways are listed further below along with an example of the form field and the submitted data.

The form fields for the example submitted data are name="one_line" and name="message", both containing text:

<input name="one_line" value="ONE LINE">

<textarea name="message">HELLO
THERE</textarea>

The way the form knows how to encode/format the data before submitting it to the form-handling software is with the enctype attribute in the form tag.

Here are the three encoding types with an example form tag and the encoded/formatted submission data for each.

  1. application/x-www-form-urlencoded
    (This is the default the browser uses whenever the form tag has no enctype attribute.)

    Spaces are converted to "+" characters. Other special characters are converted to HEX values.

    Example form tag:

    <form enctype="application/x-www-form-urlencoded" method="post" action="software.php">
    

    Example submission:

    one_line=ONE+LINE&message=HELLO%0D%0ATHERE
    
  2. multipart/form-data

    No characters are encoded. The submission data is formatted in multiple parts that are separated with a boundary composed of a special sequence of characters.

    Example form tag:

    <form enctype="multipart/form-data" method="post" action="software.php">
    

    Example submission:

    ------WebKitFormBoundaryOQ1HD4YrjOZSIQEd
    Content-Disposition: form-data; name="one_line"
    
    ONE LINE
    ------WebKitFormBoundaryOQ1HD4YrjOZSIQEd
    Content-Disposition: form-data; name="message"
    
    HELLO
    THERE
    ------WebKitFormBoundaryOQ1HD4YrjOZSIQEd--
    
  3. text/plain

    Spaces may be converted to "+" characters. The format begins a new line for each form field name. This is followed by a "=" character and then the field value. The next form field name begins another line.

    Example form tag:

    <form enctype="text/plain" method="post" action="software.php">
    

    Example submission:

    one_line=ONE+LINE
    message=HELLO
    THERE
    

For most form handling software, the default enctype="application/x-www-form-urlencoded" will work fine. Unless the form will have a file upload field.

If the form has a file upload field, enctype="multipart/form-data" is required. Most form handling software can work with this enctype, also, whether or not the form has a file upload field.

The enctype="text/plain" is a special type that might or might not be recognized by your software.

When you don't know what type of encoding/formatting your software expects, try the enctype="multipart/form-data". It works for most applications.

When the form submit button is clicked, the form data is encoded/formatted according to the enctype attribute of the form tag, then submitted to software. The software determines what the encoding/formatting is and handles the data accordingly.

Will Bontrager

Was this article helpful to you?
(anonymous form)

Support This Website

Some of our support is from people like you who see the value of all that's offered for FREE at this website.

"Yes, let me contribute."

Amount (USD):

Tap to Choose
Contribution
Method

All information in WillMaster Library articles is presented AS-IS.

We only suggest and recommend what we believe is of value. As remuneration for the time and research involved to provide quality links, we generally use affiliate links when we can. Whenever we link to something not our own, you should assume they are affiliate links or that we benefit in some way.

How Can We Help You? balloons
How Can We Help You?
bullet Custom Programming
bullet Ready-Made Software
bullet Technical Support
bullet Possibilities Newsletter
bullet Website "How-To" Info
bullet Useful Information List

© 1998-2001 William and Mari Bontrager
© 2001-2011 Bontrager Connection, LLC
© 2011-2024 Will Bontrager Software LLC