How to filter Chinese user names for php user registration

Source: Internet
Author: User
Php Tutorial user registration filters Chinese user names. in many development scenarios, Chinese names are not allowed, so we create an example today to restrict Chinese name registration, in php, we can use regular expressions to restrict Chinese names such as preg_match (quot ;...

Php Tutorial user registration filters Chinese user names. in many development scenarios, Chinese names are not allowed, so we create an example today to restrict Chinese name registration, in php, we can use regular expressions to restrict Chinese names such as preg_match ("/^ [". chr (0xa1 ). "-". chr (0xff ). "] + $/", let's look at the instance.

 Sorry, you cannot use Chinese as the user name!

"); Exit () ;}if ($ xm = 'null' | $ xm ='' | strlen ($ xm)> 10 | strlen ($ xm) <3) {echo ("

Sorry, the user is composed of 3-12aa_zz and numbers!

"); Exit ();} else {$ result = mysql tutorial _ query (" select m_uid from wk_member where m_uid = '$ xm' ") or die ('error! '. Mysql_error (); if (! Mysql_num_rows ($ result) {echo ("

Congratulations! This user can register!

");} Else {echo ("

Sorry, the user has been registered. please select another name!

") ;}} Elseif ($ ta = 0) {if (@ file_get_contents ($ xm) {echo'

The blog address is accessible.

';} Else {echo'

Sorry, the blog address you entered cannot be accessed normally

';}} Else {echo"

Sorry, the operation is invalid!

";}

Summary:
The method is very simple. you only need to obtain the user input and use preg_match to judge.

Tutorial address:

Reprinted! But please include the article address ^

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.