PHP form verification (1), php form verification
PHP Verification
Step 1: first obtain the content transmitted from the form; $ _ POST ['']; // use this function to obtain the data of the form,
POST must be capitalized, and the brackets must contain single quotation marks.Step 2: Judge 1 whether the request is submitted normally: isset (); // use this function to determine whether the request is set (exists). Example: if (isset ($ _ POST ['username']) {echo submitted normally;} else {echo submitted abnormally}; // output the content in the text box named username
It is very accurate to use the isset () function to verify whether the submission is normal.
Currently, the normal submission method is submitted through a form.
Currently, the unusual submission is not submitted through a form. For example, you can directly open the file after the action in the form. This is even an illegal submission.
Isset () is also a security measure. The receiving page must be written
Empty () function is used to determine whether the form is filled
Htmlspecialchars () is used to format the Code, so that the Code submitted by the Code cannot be executed. Security measures. The receiving page must be written
The trim () function is used to format the code and delete spaces.
The strlen () function is used to determine the Data Length. Generally, it must be no less than a few characters.
Is_number () can be understood literally. It is a function that determines whether the data is a pure number.