Courses
/
HTML5 Mastery: Complete Beginner to Advanced Course
/
Form Structure, Action, Method and Submission HTML Forms
Form Structure, Action, Method and Submission HTML Forms
<form autocomplete="on">
<input type="email" name="email" autocomplete="email">
<input type="text" name="given-name" autocomplete="given-name">
</form>
8. Complete Example
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Contact Form</title>
</head>
<body>
<h1>Contact Us</h1>
<form action="/contact" method="post">
<div>
<label for="full-name">Full Name</label>
<input id="full-name" name="full_name" type="text" required>
</div>
<div>
<label for="contact-email">Email Address</label>
<input id="contact-email" name="email" type="email" required>
</div>
<div>
<label for="message">Message</label>
<textarea id="message" name="message" rows="5" required></textarea>
</div>
<button type="submit">Send Message</button>
</form>
</body>
</html>
9. Important Security Notes
- Use HTTPS when transmitting information.
- Validate submitted data on the server even when browser validation exists.
- Use appropriate authentication, authorization and CSRF protection where needed.
- Never assume that hiding or disabling a field makes its data trustworthy.
Common Mistakes
- Forgetting the name attribute.
- Using GET for passwords or other sensitive data.
- Expecting an HTML form to save information without a backend.
- Using file inputs without multipart/form-data for a standard POST upload.
- Using a submit button when the intended action is to reset or perform a separate task.
Practice Exercises
- Create a search form using GET with a search field named q.
- Create a registration form using POST with username and email fields.
- Create a document upload form using multipart/form-data.
- Explain why the name attribute matters during submission.
Revision Quiz
- Which element groups controls for form submission?
- Which attribute identifies the URL receiving submitted data?
- Which method commonly places form values in the URL?
- Which attribute is needed for a control to be included under its field name in normal form submission?
- Which enctype is commonly required for file uploads?
- Does POST automatically encrypt form data?
Answer Key and Explanations
- form — It groups form controls and defines submission behavior.
- action — It specifies the submission destination.
- GET — Values are commonly included in the query string.
- name — It supplies the field name in submitted data.
- multipart/form-data — It supports transmitting files with form data.
- No. HTTPS provides transport encryption; POST alone does not.
Rate this course
★
★
★
★
★
5.0 · 1 rating
Stars show on this course. Your written note stays private.