I learned to write forms over the past two days. To be noted. Example 1 (POST submission form ):
The code is as follows:
<BR> Chunkify Form <BR>
The code is as follows:
<BR> Chunkify Word <BR>
$ Word = $ _ POST ['word'];
$ Number = $ _ POST ['Number'];
$ Chunks = ceil (strlen ($ word)/$ number );
Echo "The $ number-letter chunks of '$ word' are:
\ N ";
For ($ I = 0; $ I <$ chunks; $ I ++ ){
$ Chunk = substr ($ word, $ I * $ number, $ number );
Printf ("% d: % s
\ N ", $ I + 1, $ chunk );
}
?>
Html page.
Page processed by php after the form is submitted. In this example, I enter a word, and then give it a length, and divide the word into blocks of that length.
The POST method is used to submit a form.
Example 2 (single choice, GET accept form ):
The code is as follows:
If (array_key_exists ('s ', $ _ GET )){
$ Des = implode ('', $ _ GET ['Att ']);
Echo "You have a $ des personality .";
}
?>
Example 3 (multiple options, GET accept form ):
Note thatThe underline tells GET that you are transmitting an array, while the black part indicates that the selection box is changed to multiple selection boxes. The code is as follows: If (array_key_exists ('s ', $ _ GET )){$ Des = implode ('', $ _ GET ['Att ']);Echo "You have a $ des personality .";}?> Example 4 (check box checkbox): the same name = "att []" indicates that GET transmits an array, and checked indicates that this option is the initial default option. in the same example, you can also add selected = "selected" to the tag.Select multiple options by default. The code is as follows: If (array_key_exists ('s ', $ _ GET )){Echo"";Print_r ($ _ GET );Echo"";If (is_null ($ _ GET ['Att ']) exit;$ Des = implode ('', $ _ GET ['Att ']);Echo "You have a $ des personality .";}?> Example 5 (single answer): Note that the same option must have the same name The code is as follows: When you click a single-choice button, the button changes to the selected status, and all other buttons change to the unselected status. Example 6 (stick form) The code is as follows: $ F = $ _ POST ['FA '];?> If (! Is_null ($ f )){$ C = ($ F-32) * 5/9;Printf ("%. 2lf is %. 2lfC", $ f, $ c );}?> Are some simple form processing ~Knowledge make me stronger!