As mentioned above, it is very convenient to submit the form information in PHP. But how long is the lifecycle of the variable in the submitted form information? In this article, I will talk about this title. The form parameters are passed to the next handler, which is unquestionable. By
As mentioned above, it is very convenient to submit the form information in PHP. But how long is the lifecycle of the variable in the submitted form information? In this article, I will talk about this title.
The form parameters are passed to the next handler, which is unquestionable. Because we once had such an example. But will it still be passed to the next handler?
The answer is No! The parameters submitted by a Form are only transmitted to the first handler, which does not work in the next handler. Let's take a look at the following example:
File: table.html
Form submission
File: deal-1.php
Echo'';
Echo 'Do you like $ start, right?
';
Echo 'try to see if it will be passed down ';
Echo'';
?>
File: deal-2.php
Echo'';
Echo 'Do you want to say $ start? ';
Echo'';
?>
From the above example, we can see that the result of deal-1.php processing is (if we enter "Zhang Xueyou" in table.html "):
Do you like Zhang Xueyou?
Try again
Clarify that the form commits the variable $ start to the deal-1.php, and in the display result of the deal-1.php, if we click the link "Try Again, the results of processing deal-2.ph lead p are:
Do you say yes?
Obviously, $ start is not passed to deal-2.php. But how can we extend the life cycle of $ start? Actually, this is very simple, just use the parameter transfer method. For example, under the license, we can change the deal-1.php to this:
Echo'';
Echo 'Do you like $ start, right?
';
Echo 'try to see if it will be passed down ';
Echo'';
?>
Minute program, you will invent just in the deal-1.php after adding a sentence "? Start = $ start ", and the role of this operation is parameter transfer. Such as: http://zhuagk12.oso. export com.cn/cartoon.php? No = 1 its? And no is the parameter name. The value is 1. In this way, $ no is generated in the cartoon. php program, and its value is 1. If two or more signature parameters are input, separate them. Such as: http://zhuagk12.oso.com.cn/cartoon.php? No = 2 & debug = 1
To extend the life cycle of parameters, we can also use cookies or sessions to implement them. we will not describe them here. you will see their usage in future articles.
Cookie is often referred to as a "database" or "small dessert ". It is a small file stored in the client browser. It is developed to solve a connection of HTTP without memory, and can be used to track the application or confirm the returned application. PHP provides the setcookie () function to set the Cookie. Cookies are part of the response HTTP header. Therefore, the setcookie () function must be called before webpage data is transmitted to the browser. This is the same as calling the header () function.