PHP verifies that the user name starts with a letter and validates the password instance _php tutorial

Source: Internet
Author: User

PHP verifies that the user name starts with a letter and validates the password instance


This article describes how PHP verifies that a user name begins with a letter and validates the password. Share to everyone for your reference. Specific as follows:

Verify that the user name starts with a letter and that the authentication password is only a combination of numbers and letters, three common validation functions: Verify the Mailbox address format, verify that the password is only a combination of numbers and letters, and verify that the user name starts with a letter, which is used when the user registers or submits the form.

The code is as follows:

function Is_email ($email)
{
if (Preg_match ("/[a-za-z0-9]+@[a-za-z0-9]+.[ a-z]{2,4}/", $email, $mail))
{
return true;
}
Else
{
return false;
}
}

/**
* Verify that the user name starts with a letter
*/

function Is_user_name ($user)
{
if (Preg_match ("/^[a-za-z]{1}" ([a-za-z0-9]|[. _]) {3,19}$/", $user, $username))
{
return true;
}
Else
{
return false;
}
}

/**
* Verify that the password is only a combination of numbers and letters
*/

function is_psd ($PSD)
{
if (Preg_match ("/^ (w) {4,20}$/", $PSD, $password))
{
return true;
}
Else
{
return false;
}
}

I hope this article is helpful to everyone's regular expression learning.

http://www.bkjia.com/PHPjc/930078.html www.bkjia.com true http://www.bkjia.com/PHPjc/930078.html techarticle PHP verifies that the user name starts with a letter and validates the password instance This article describes how PHP verifies that a user name begins with a letter and validates the password. Share to everyone for your reference. ...

  • 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.