Author: Sun Sports, you may have noticed that, in all the examples we have given you so far, we have given you two pages-a simple HTML page with a form, and another php (as the mainstream development language) script used to process form input and generate corresponding output. However, as the current mainstream development language SyntaxHighlighter. all () Author: Sun Sport
You may have noticed that, in all the examples we have given you so far, we have given you two pages-a simple HTML page with a form, and another php (as the mainstream development language) script used to process form input and generate corresponding output. However, php (as the mainstream development language) provides a elegant way to combine the two pages with the $ submit variable.
As you know, once a form is submitted to php (as the current mainstream development language) scripts, all form variables become php (as the current mainstream development language) variables. Now, in addition to user-defined variables, a variable named $ SUBMIT is created each time you click "submit" in the form. Therefore, by testing whether the variable exists, a smart programmer can use only one page to initialize the form and generate the submitted output.
Let's demonstrate to you-we use a page to implement the above lucky cookies example, including the initial date selection page and the lucky Cookies page below. Let's assume that the new php (as the mainstream development language) file is also called "cookie. php (as the mainstream development language )"
<Tr>
<Td align = "center">
Pick a day
</Td>
<Td align = "right">
<Select name = "day">
<Option value = "Monday"> Monday
<Option value = "Tuesday"> Tuesday
<Option value = "Wednesday"> Wednesday
<Option value = "Thursday"> Thursday
<Option value = "Friday"> Friday
<Option value = "Saturday"> Saturday
<Option value = "Sunday"> Sunday
</Select>
</Td>
</Tr>
<Tr>
<Tr>
<Td colspan = "2" align = "center">
<Input type = "submit" name = "submit" value = "Hit me! ">
</Td>
</Tr>
</Table>
</Form>
</Body>
</Html>
<?
}
Else
{
// If $ submit does exist, the form has been submitted.
// Use the switch () function for processing.
// The decision variable here is the date selected by the user
Switch ($ day)
{
// First case
Case "Monday ":
$ Fortune = "do not make everything simple and effective when you can find a complicated and wonderful way to do everything ";
Break;
// First case
Case "Tuesday ":
$ Fortune = "Is life a bridge to games? -You must use some clever tricks. ";
Break;
Case "Wednesday ":
$ Fortune = "what makes people with clear minds never go crazy in this world? ";
Break;
Case "Thursday ":
$ Fortune = "Don't be crazy, be fun ";
Break;
Case "Friday ":
$ Fortune = "just follow the times and follow the ethos. when you get an improvement, you will find that the type is a devil. ";
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