Send form content in PHP email (3)-Display error messages based on user input

Source: Internet
Author: User
Tags php email

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

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.