This example uses the POST method when submitting the form data:
<!DOCTYPE html>
<html>
<body>
<h2>The method Attribute</h2>
<p>This form will be submitted using the POST method:</p>
<form method="post" action="/php/actionPagePost.php" target="_blank">
<label for="fname">First name:</label><br>
<input type="text" id="fname" name="fname" value="Bintu"><br><br>
<label for="lname">Last name:</label><br>
<input type="text" id="lname" name="lname" value="Chaudhary"><br><br>
<input type="submit" value="Submit">
</form>
<p>After you submit, notice that, unlike the GET method, the form values is NOT visible in the address bar of the new browser tab.</p>
</body>
</html>
Notes on POST:
- Appends the form data inside the body of the HTTP request (the submitted form data is not shown in the URL)
- POST has no size limitations, and can be used to send large amounts of data.
- Form submissions with POST cannot be bookmarked
Tip: Always use POST if the form data contains sensitive or personal information!