Home >Backend Development >PHP Tutorial >PHP verifies whether the username starts with a letter and verifies the password_PHP tutorial

PHP verifies whether the username starts with a letter and verifies the password_PHP tutorial

WBOY
WBOYOriginal
2016-07-15 13:22:13877browse

Verify whether the username starts with a letter and verify that the password can only be a combination of numbers and letters
Three commonly used verification functions Verify email address format Verify password can only be a combination of numbers and letters Verify whether the username starts with a letter code, this is used when users register or submit forms.

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;
  }
 } /**
  * 验证用户名是否以字母开头
  */


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;
  }
 } /**
  * 验证密码只能为数字和字母的组合
  */


function is_ps教程d($psd)
 {
  if (preg_match("/^(w){4,20}$/",$psd,$password))
  {
      return true;
  }
  else
  {
      return false;
  }
 }

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/447003.htmlTechArticleVerify whether the username starts with a letter and verify that the password can only be a combination of numbers and letters. Three commonly used codes The verification function verifies the email address format and the verification password can only be numbers and letters...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn