[Original]ajax implementation of user Registration function tutorial Three

Source: Internet
Author: User
Tags chr strlen

[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>");
}
}
?>

Related Article

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.