PHP page jump loss $ _ POST data

Source: Internet
Author: User
PHP page jump loss $ _ POST data test. php content: PHPcode $ _ POST [& quot; aa & quot;] 111; header (& quot; Location: & quot ;. & quot; test1.php & quot;); exit (0); test1.php code: PHPcode for help: PHP page jump loss $ _ POST data

PHP page jump loss $ _ POST data

The content of test. php is as follows:
PHP code
  $_POST["aa"] = 111;header("Location: " ."/test1.php");exit(0);


The test1.php code is as follows:
PHP code
  var_export($_POST);


Enter http: // localhost/test. php in the URL to jump to the test1.php page.
However, the output $ _ POST content is empty...

Ask for help, where is the problem.

------ Solution --------------------
Do you know what $ _ POST is?
------ Solution --------------------
Http post variable: $ _ POST
Note: PHP 4.1.0 and later versions are used. In earlier versions, $ HTTP_POST_VARS is used.

An array composed of variables passed through the http post method. Is an automatic global variable.

This is a "superglobal", or it can be described as an automatic global variable. This only means that it is valid in all scripts. You do not need to use global $ _ POST; to access a function or method, just like using $ HTTP_POST_VARS.

$ HTTP_POST_VARS contains the same information, but it is not an automatic global variable (note: $ HTTP_POST_VARS and $ _ POST are different variables, and PHP processes them differently ).

If the register_globals command is set, these variables are also available in all scripts; that is, the $ _ POST and $ HTTP_POST_VARS arrays are separated. For more information, see the security section using Register Globals. These independent global variables are not automatic global variables.

Post is used to receive data in the background only when the form is submitted.
------ Solution --------------------
It's strange to get it. you don't have it at all. $ _ POST passed the data. please refer to the http protocol manual.

You can pass data through url parameters. test1.php uses $ _ GET to GET data.

PHP code
$ _ POST ["aa"] = 111; header ("Location:". "/test1.php? Aa = ". $ _ POST [" aa "]);
------ Solution --------------------
The jump cannot pass the parameter
Unless you use the framework that can assign values with passing parameters (not the real jump is the output page)
------ Solution --------------------
Header ("Location:/test1.php") only tells the browser to jump to test1.php.
I can't figure out why I want to design the program so that the raw data is directly submitted to test1.php for processing, which easily solves the problem.
Discussion

Thank you for your answers. $ _ POST understands a little.
How can I return the data processed in the background to the page? No $ _ POST?

------ Solution --------------------
You still have to look at the php curl!

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.