Php date email address user name verification instance-PHP source code

Source: Internet
Author: User
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;
}
?>

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.