I learned to write forms over the past two days. To be noted.
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.
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 nameThe 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. The Code is as follows: $ F = $ _ POST ['fa '];?> If (! Is_null ($ f )){$ C = ($ f-32) * 5/9;Printf ("%. 2lf is %. 2lfC", $ f, $ c );}?> Knowledge make me stronger!