CSCI 121 - Lecture 8 - Advanced Forms
Topics Covered
- <form> - Form element
- action attribute - defines how to submit a form
- The action attribute defines the action to be performed when the form is submitted.
- Normally, the form data is sent to a web page on the server when the user clicks on the submit button.
- method attribute - defines the form submission method
- The method attribute specifies the HTTP method (GET or POST) to be used when submitting the form data:
- <form action="action_page.php" method="get">
- The default method when submitting form data is GET.
- However, when GET is used, the submitted form data will be visible in the page address field.
- Additional facts about using GET:
- Appends form-data into the URL in name/value pairs
- The length of a URL is limited (about 3000 characters)
- Never use GET to send sensitive data! (will be visible in the URL)
- Useful for form submissions where a user want to bookmark the result
- GET is better for non-secure data, like query strings in Google
- <form action="action_page.php" method="post">
- Always use POST if the form data contains sensitive or personal information. The POST method does not display the submitted form data in the page address field.
- POST has no size limitations, and can be used to send large amounts of data.
- Additional facts about using POST:
- Appends form-data inside the body of the HTTP request (data is not shown is in URL)
- Has no size limitations
- Form submissions with POST cannot be bookmarked