We use the POST method to send data from a dynamic website form to the server. When a user fills the website form and clicks on the submit button, then the information goes to the server only with the help of the POST method.
In the previous tutorial,we discussed the GET method in PHP. There is a slight difference between the GET and POST methods.
POST Method in PHP
The POST method in PHP stands for send information to the server without any limit.
POST method transfers information via HTTP headers.
.If you want to create a dynamic website, then you should have complete knowledge about the post method.
You can use the post method for security purposes.
The Post method does not contain any encoded value in page URL.
In the GET method, the encoded value is separated by the? (Question Mark)
In the above syntax, $ _GET[ ..] is an array of PHP and within the array. Use any variable name for form values. When you create a login form, you define some variables that bring values from the HTML form. We pass the variables name inside the $_POST[..] .
When you create a form and you get some fields inside the form.
You have to define the name of every field.
After complete the HTML form, you have to use these for fields name inside the $_POST[..] array. Form field values are sent to the server through the POST method.
It is a very simple process.
Example of the POST method
In the below example , we create a HTML form and a PHP script for the POST method .
In the above example, we have created an HTML form. There are two fields inside the HTML form. The first field(text box) is for username and the second field(text box) for the password.
1. To handle the form data , we use the POST method.
2. Create a PHP script for the POST method.
3. In the PHP script, we use the "if the condition" for handling the submit process.
4. Now use the $_POST[...] associative array and use the variable name. The variable name should be the same name of HTML field name.
5. Echo the values on the page .
More about post method
1. The POST method transfers the information to the server without any issue. .
2. Send unlimited data to the server using the POST method.
3. The POST method helps to send ASCII and binary data.
4. It goes through the HTTP header. The security depends on the HTTP protocol.
5. The POST method secures your sensitive information. Never visible values in page URL.
6. You can use the POST method for login purposes. It's secure your privacy.