Some special situations of get and post

Source: Internet
Author: User
This article mainly introduces some special situations of get and post. For more information, see

This article mainly introduces some special situations of get and post. For more information, see

I recently encountered the following problems during my work on file upload:

Submit the form to a url with parameters (such as res. php? Param = aaa). What is the result?

Next we will test the get and post content from several examples. First, let's take a look at the simplest

<? Phpecho $ _ GET ['param'];?>

Submit the url with this parameter in get mode. The result is that the corresponding value is overwritten, and the obtained param is bbb.
What if the parameter in the url is different from the name in the form? See the following test example.

<? Phpecho $ _ GET ['param1']; echo"
"; Echo $ _ GET ['param2'];?>

The result shows that the value of param2 is obtained correctly, but the value of param1 is not obtained. It indicates that the parameters of the original url are removed when the request is submitted in get mode.
Next, let's take a look at the post submission process.

First, let's take a look at the situation where the name value is the same

<? Phpecho "get =". $ _ GET ['param']; echo"
"; Echo" post = ". $ _ POST ['param'];?>

In this case, the output result is aaa in get mode and bbb in post mode, which means that the get and post methods are isolated from each other in this case.
Next, let's take a look at how to get the parameters following the url through post.

<? Phpecho "get =". $ _ GET ['param2']; echo"
"; Echo" post = ". $ _ POST ['param1'];?>

In this case, all obtained parameters are null, so the get and post parameters in php are isolated from each other.
However, when you use java to upload files today, you can correctly retrieve all the data, that is, you can use the request in the servlet to obtain the form data of the post or the get data after the url. after all, the methods for obtaining parameters in servlet are the same.

,

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.