A few elements recorded in form validation
1.htmlspecialchars (), which is used to escape the special characters entered by the user into normal character, such as HTML characters such as < and > are replaced with < and >
2.$_server["Php_self"] is a super global variable that returns the current page script name
3.trim () to remove extra spaces, etc.
4.stripslashes () to remove multiple input backslashes from the user
Second simple form validation functions
function Test_input ($str) {$str = Trim ($STR),//$str = Stripslashes ($STR),//Remove the backslash $str = Htmlspecialchars of the user input ($str );//convert special character to normal character return $str;}
Third, the form must fill in the prompt code
1.php code, verify that the input box is empty, add an error message for display in HTML, non-null to validate and process input
PHP code snippet for inserting output error information in 2.HTML code such as *
$EMAILERR to save the error information variable, the start is empty.
Simple example:
* Must be filled
"; echo" Name: ", $name; echo"
E-mail: ", $email; echo"
URL: ", $website; echo"
Comment: ", $area; echo"
Gender: ", $gender;? >
To display a drawing:
Iv. Retention of form data
In the above code, just change the followingAdd a PHP fragment to the tag:
For elements, simply add the PHP fragment between <textarea>
On the radio, more troublesome, inAdd code in: