When creating an HTML form, there are two methods for transmitting
the data entered by the user, the GET
and POST
method which
respectively transmit the data in the navigation bar and in the
HTTP request.
The default method is the GET
method. The data will be visible
in the URL, for example:
/processing.php?firstname=Pierre&lastname=Dupont
The processing PHP page will receive data in a variable (an array) named $_GET
.
Some remarks and precautions:
<form action="process.php" method="get">
<!-- Form fields -->
</form>
With the POST method, the form data is transmitted in the HTTP request. If
the site uses an SSL certificate (domain starting with https
instead
of http
), data will be encrypted. This method is more secure.
The processing page will receive data in the variable $ _POST
.
<form action="process.php" method="post">
<!-- Form fields -->
</form>
Modify the script in the following example so that the data is transmitted with the GET method. Check the URL of the processing page after form is submitted.