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 ^