Home > Article > Backend Development > POST() method and GET() method for submitting form data in php
Submitting and obtaining form data is the most commonly used operation in form applications. It is often necessary to PHP in the background to obtain various data submitted by users in the foreground form page from the foreground page. There are two ways to transfer form data, one is the POST() method, and the other is the GET() method. The specific method of obtaining data is specified by the method attribute of the
Note: In the above code, the method attribute of the form form specifies The delivery method of the POST() method, and the data page is specified as index.php through the action attribute. Therefore, when the "Submit" button is clicked, the information in the text box can be submitted to the server, and the running results are as follows:
Use the GET() method Submit the form
The GET() method is the default method of the method attribute in the
Run this example, in the text box Enter the user name and password in the "Submit" button, and the information in the text box will be displayed in the URL address bar, as shown in the following figure:
here It can be clearly found that the GET() method will expose parameters in the address bar. If the parameters passed by the user are non-confidential parameters (such as id=8), then it is feasible to use the
GET() method to pass data; if the parameters passed by the user are confidential parameters (such as passwords, etc.), use Passing data this way is unsafe. The solution to this problem is to replace the default GET() method of the method attribute in the form with the POST() method.
The above is the detailed content of POST() method and GET() method for submitting form data in php. For more information, please follow other related articles on the PHP Chinese website!