PHP determines whether the form form is submitted in detail

Source: Internet
Author: User
Tags html header http post php form
PHP to determine whether the form is submitted

When we submit a form through submit, we care about whether a large pile of data that is filled in the form is submitted to the background. Here you need to make a judgment, using PHP code to determine whether the form data is submitted generally in the following form:

<?phpif (Isset ($_post[' submit ')) {   echo "data was submitted";}?>

Description: Isset---check whether the variable is set, the return value is like the following several forms.

Returns FALSE if the variable does not exist

Returns FALSE if the variable exists and its value is null

Returns TURE if the variable exists and the value is not NULL

When checking multiple variables at the same time, returns TRUE if each item meets the previous requirement, otherwise the result is FALSE.

PHP form submission Method GET and POST requests

The Get method puts the data and the requested URL address together, and the results of the browsing are placed in the buffer. Because get is passed behind a URL, the size of the data passed is limited.

The data sent by post is stored separately in the package, not following the URL address, so it allows a large amount of data to be sent, but each time the client sends a request to the server and is not stored in the cache. You can use $_post[] to receive POST data. In the URL, no data information is displayed.

1. Get is the data that is fetched from the server, and post is the data that is sent to the server.
2. Get is the URL where the parameter data queue is added to the Action property of the submission form, and the value corresponds to the field one by one in the form, which is visible in the URL. Post is the HTTP post mechanism that places the fields within the form with their contents in the HTML header, along with the URL address referred to by the Action property. The user does not see the process.
3. For the Get mode to submit the form data, the server side uses $_get[' name '] to get the value of the variable, for POST form data submission, the server side with $_post[' name '] to obtain the submitted data, of course, both can be $_request[' Name '] to get form data. When submitting form data for REQUEST, the server uses $_request[' name ' to get the value of the variable, but this method is seldom used.
4. Get transmits a small amount of data and cannot be greater than 2KB. Post transmits a large amount of data, which is generally not restricted by default. In theory, however, it is generally considered not to exceed 100KB.
5. Get security is very low and post security is high.
6. Get form values can be obtained through _get, but parameters set by the action URL are always not available, <form method= "get" action= "A.php?b=b" > <form method= " Get "action=" a.php "> is the same, that is, in this case, the Get method ignores the argument list behind the action page. The Post form value can be obtained through _post, but parameters set through the action's URL parameter can not be obtained through _post. Action=test.php?id=1 This is the Get mode value, you can use $_request and $_get to accept the value, but not the Post method to obtain the value, even if the form is submitted by post. Where, when submitting a form, if there are parameters in the action, it is best to use the post form only, for the data in the form, directly through post, for parameters in action, child labor get gets.

When doing a data query, it is recommended to use the Get method, and when doing data addition, modification or deletion, it is recommended to use POST method. The
request is to read the get-and-read post, while it is present, overwriting the previous variable.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.