When we submit this farm the data from it inputs are shown in the you owl.
This is fine for a search farm for instance.
But what if it's a sign up are logging farm containing a password for example let's change this farm
to have a username and password input and will look at different types of inputs in more detail next.
In a browser when we type a user name and password and submit the farm the data as shown in the query
string.
In addition to being visible in the address bar the U R L is also saved in the browser's history on
a shared computer.
Anyone could see it.
There are two methods.
A farm can use to send its data.
The method the farm uses is specified using the method attribute.
Get is the default which sends data in the query string.
As we've just seen so if you specify the method as get are you don't specify a method then the data
are sent in the query string.
However far sensitive data we don't want data to be seen in the query string.
The other method farms can use is called post.
This sends data separately from the query string.
So now if we enter some values into the form and submit it the values are sent but not shown in the
query string.
Let's add some code so that we can see what's being submitted.
Remember as we're not specifying a value for the action attributes of this farm.
It'll be submitted to itself.
Using the get method.
The data are available in the getaway as we've seen using the post method.
The data are available in the post array.
So let's dump out the entire array here at the top like that.
If we visit the party again initially we're shown an empty array because nothing has been submitted.
If we enter some data and submit the farm we can see the values we put in the farm in the post array.
But they're not shown in the you O L in the address bar.
Additionally we can detect which method of form used when it was submitted by checking the request method
element of the server super global.
So here at the top let's check this.
Value is equal to post so we only print out the array if the farm was submitted.
So now when we first visit the farm an empty rate isn't printed out.
But when we add some values and submit the farm the array is printed out.
Note that the value in the server array is returned in uppercase which is why we compare it to the word
post in capitals but in the astm attribute we put it in lower case.
You can use either in the astm Al but the convention is to put it in lower case like this.
So which method should we use as the get method to sends its data in the U R L.
You can bookmark the result but also because of this however we shouldn't use get for sensitive data
like a farm were using to log in are send data to be inserted into a database.
In addition the uml does have a size limit in some browsers which can be about 3000 characters so you
can't send a lot of data using the get method.
The Post method sends its data separately to the U R L So the data are not shown in the address bar
of the browser so we can't bookmark the results of submitting a farm using the post method.
However if we're sending data to the server to be used file log in after data to be saved to the database
then we need to use the post method.
There's no size limit to how much data we can send in a farm that uses the post method.
So if you just getting some data from the web server for example search results you'll get if you're
changing data on the server inserting updating are deleting your record in the database.
For example use post.