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