The topic is to do a and demo almost a meaning, give the hint should be very sufficient, including a variety of functions have.
Using this method we can save an HTML file by mentioning how to detect a commit in two ways that PHP checks whether the form is submitted.
$_post is an array (super global variable), and if the page is requested by post, the corresponding content is stored in the array.
The empty () function has been said before, and a isset () is also described later in this article
And it's basically understandable.
Source:
The code is as follows |
Copy Code |
<! DOCTYPE html> <meta charset= "Utf-8" > <title> Registration System </title> <body> <?php if ($_server[' Request_method ']!== ' POST ') { ?> <form action= "form-post.php" method= "POST" > User name: <input type= "text" name= "username" ><br/> Password <input type= "password" name= "password" ><br/> <input type= "checkbox" Name= "agree" > Consent License Agreement <br/> <input type= "Submit" name= "Submission" value= "submitted" > </form> <?php } else { $problem = FALSE; if (Empty ($_post[' username ')) { Echo ' Please enter user name <br/> '; $problem = TRUE; } if (Empty ($_post[' password ')) { echo ' Please enter password <br/> '; $problem = TRUE; } if (Empty ($_post[' agree ')) { Echo ' You must first agree to the license agreement <br/> '; $problem = TRUE; } if (! $problem) { Echo ' Echo ' Welcome '. $_post[' username ']. ' You have successfully registered, your password is '. $_post[' password ']; } } ?> </body> |
About
Empty () function parameter is a non-zero or Non-zero value, the empty () returns false:
"", 0, "0", Null,false,array (), var $var is considered null, and returns True if the function is empty.
True if the Isset () parameter exists, returns False if Isset () is used to test a variable that is set to NULL, or if a variable is freed using unset (), returns false.
Review: null byte ("") is not equivalent to the null function of PHP.
Note: Determine if a variable exists and is not null:!empty ($VAR)-Recommended