SE452: GET vs. POST [5/20] ![]() ![]() ![]() |
The form data is submitted as part of the HTTP request as a sequence of URL-encoded name-value pairs.
Data needs to be URL encoded, since certain characters that can be submitted as part of a request aren't allowed in a URL (like a space for example...)
The GET method encodes the name-value pairs onto the request URI (i.e. Visible in the Location of the browser)
The POST method encodes the name-value pairs in the message body of the request. (invisible to the user, but not encrypted)
GET is the default method
Here is an example HTML form:
And the source to make it:
<html>
<head><title>Login Page</title></head>
<body>
<form method="post" action="/se452/login">
<h4>Enter your User ID and Password and click Login</h4>
<table cellpadding='2' cellspacing='1'>
<tr>
<td>User ID</td>
<td><input type="TEXT" size="15" name="userid"></input></td>
</tr>
<tr>
<td>Password</td>
<td><input type="PASSWORD" size="15" name="password"/></td>
</tr>
<tr>
<td colspan='2'>
<center><input type="SUBMIT" value="Login" /></center>
</td>
</tr>
</table>
</form>
</body>
</html>