[Original]ajax implementation of user Registration function tutorial Three
This tutorial by the original site, reproduced please specify the place
Author: www.111cn.net
Email: drise@163.com
qq:271728967
//
Now in step three, we're going to write the type.php file, which is to determine if the username exists, and then the data to the user.
<?php
Header ("content-type:text/html;charset=gb2312");//To keep it from garbled, set the document encoding to GB2312
$XM =strreplace (isset ($_get[' txt '))? $_get[' txt ']: ' null '; Get user name
if (Preg_match ("/^[". Chr (0XA1). " -". Chr (0xFF)."] +$/", $XM)) {//To determine whether the first user name is Chinese characters,
Echo ("<div id= ' phperblog_showinfo_red ' > Sorry, can't use Chinese as username!") </div> ");
Exit ();
}
if ($XM = = ' null ' | | | $xm = = ' | | strlen ($XM) >10 | | strlen ($XM) <3) {//judge the legality of username
Echo ("<div id= ' phperblog_showinfo_red" > Sorry, the username you entered is not legal, the user is composed of 3-10aa_zz and numbers!) </div> ");
Exit ();
}else{
$result =mysql_query ("Select uname from tablename where uname= ' $xm") or Die (' Error! ') Error system Busy.....plase wait! ");
if (!mysql_num_rows ($result)) {
Echo ("<div id= ' Phperblog_showinfo_reg ' > Congratulations!") Username ". $xm." Not yet registered, you can register! </div> ");
}else{
Echo ("<div id= ' phperblog_showinfo_red ' > Sorry, the user has registered please choose another name!</div>");
}
}
?>