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

Source: Internet
Author: User
Tags regular expression

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

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

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 password can only be 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 the regular expression learning.

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.