This section is not much, mainly by two places to be aware of:
1, use In_array to determine whether a variable is in an array, which is the basis for us to determine whether a form will be entered or wrong;
2, PHP conditional statements can be separated by <?php?> tags, that is, the first in a different label, the middle part will still be as part of the conditional statement, only when the judgment is true to show or execute.
Look at the code:
1<?PHP2 $missing=Array();//used to store information that the user has not filled out;3 $error=Array();//used to store information that the user fills in errors;4 //How do you identify information that is not filled in or filled out, and then store it in the appropriate array? This is the content of another section. 5?>6<label>Name:7<?phpif($missing&&In_array(' Name ',$missing)) {?>8<spanclass= "Waring" > You did not fill in the name! </span>9<?php}?>Ten One<?PHP A if($error&&In_array(' Name ',$error)){ -?> -<spanclass= "Waring" > You fill in the name format is not legal! </span> the<?php}?> -</label>
As can be seen from the above, we are how to determine whether a form is not filled out, or fill in the wrong, we respond to different conditions to change the display of our error message.
Send form content in PHP email (3)-Display error messages based on user input