Problem Statement
Which HTTP method is typically used for sending sensitive form data?
Explanation
POST is the HTTP method typically used for sending sensitive form data. When you use method equals POST, the form data is sent in the request body rather than in the URL. This makes POST more secure than GET for sensitive information like passwords, credit card numbers, or personal details. POST data does not appear in the browser history or server logs. It also has no size limitations, unlike GET which is limited by URL length. POST is used for operations that change data on the server, such as creating accounts, submitting orders, or updating profiles. GET is used for retrieving data without side effects, such as search queries. Understanding when to use GET versus POST is important for web security and follows REST principles.
Code Solution
SolutionRead Only
<!-- POST for sensitive data --> <form action="/login" method="POST"> <input type="email" name="email" required> <input type="password" name="password" required> <button type="submit">Login</button> </form> <!-- GET for search (not sensitive) --> <form action="/search" method="GET"> <input type="text" name="q" placeholder="Search"> <input type="submit" value="Search"> </form> <!-- POST for registration --> <form action="/register" method="POST"> <input type="text" name="username"> <input type="email" name="email"> <input type="password" name="password"> <button type="submit">Create Account</button> </form>
Practice Sets
This question appears in the following practice sets:
