Author: Hua honglang
Body:
As mentioned above (PHP syntax (2), it is very convenient for PHP to submit form information. But how long is the lifecycle of the variable in the submitted form information? This article will talk about this issue.
The parameters of the form are passed to the next process. Program This is unquestionable. Because we have 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
<HTML>
<Head> <title> form submission </title>
</Head>
<Body>
<Form action = "deal-1.php">
Enter your favorite artist: <input type = "text" name = "start" size = 20>
<Input type = "Submit" value = "Yes, send it">
</Form>
</Body>
</Html>
File: deal-1.php
<? PHP
Echo "<HTML> <body> ";
Echo "You like $ start, right? <Br> ";
Echo "<a href = \" deal-2.php \ "> try again </a> ";
Echo "</body> ?>
File: deal-2.php
<? PHP
Echo "<HTML> <body> ";
Echo "would you say $ start? ";
Echo "</body> ?>
From the above example, we can see that the result of deal-1.php processing is (we entered "Zhang Xueyou" in table.html "):
Do you like Zhang Xueyou, right?
Try again
Note 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 processing result of the deal-2.ph lead P is:
Do you say yes?
Obviously, $ start is not passed to deal-2.php. But how can we extend the lifecycle of $ start? In fact, this is very simple, just use the parameter transfer method. For example, under the license, we can change the deal-1.php to this:
<? PHP
Echo "<HTML> <body> ";
Echo "You like $ start, right? <Br> ";
Echo "<a href = \" deal-2.php? Start = $ start \ "> try again </a> ";
Echo "</body> ?>
Minute program, you will find that just added a sentence after the deal-1.php "? 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
We can also use cookies or sessions to extend the lifecycle of a parameter.ArticleYou will see their usage.
-- (To be continued )--