Ec (2); & lt; formid & quot; form1 & quot; name & quot; form1 & quot; method & quot; post & quot; action & quot; & gt; & nbsp; & lt; label & gt; name & nbsp; & lt; inputname & quot; name & quot; type & quot; text & quot; id script ec (2); script
// This function is mainly used to check whether the submitted form data is incorrect (validate)
// In practical applications, user input data validation and filtering are related to program security and are very important and essential.
// $ _ POST will not be directly put into the function when writing the actual application. This is a palliative solution. I hope you can correct it.
If ($ _ POST)
{
Form_error ();
}
Function form_error (){
$ _ POST ['name'] = trim (strip_tags ($ _ POST ['name']); // This is actually a Filter
$ Len_name = strlen ($ _ POST ['name']);
If ($ len_name> 30 | $ len_name <2 ){
$ Msg = 'name length must be greater than 2 and less than 30
';
}
$ Date = explode ('-', $ _ POST ['birthday']);
If (sizeof ($ date )! = 3 ){
$ Msg. = 'date format Error
';
} Else {
If (! Checkdate ($ date [1], $ date [2], $ date [0]) {
$ Msg. = 'date is incorrect
';
}
}
If (! Eregi ("^ [a-z '0-9] + ([. _-] [a-z '0-9] +) * @ ([a-z0-9] + ([. _-] [a-z0-9] +) + $ ", $ _ POST ['e-mail ']) {
$ Msg. = 'mailbox format error ';
}
Return $ msg;
}
?>