[Original] ajax user registration function tutorial 3

Source: Internet
Author: User

// [Original] ajax user registration function tutorial 3

This tutorial is original on this site.

Author: www.drise.cn

Email: drise@163.com

QQ: 271728967

//

Now the third step is to write the type. php file, which is used to determine whether the user name exists and then send the data to the user.

<? Php
Header ("Content-type: text/html; charset = gb2312"); // set the document encoding to gb2312 to prevent gibberish.
$ Xm = Strreplace (isset ($ _ GET ['txt '])? $ _ GET ['txt ']: 'null'); // obtain the user name
If (preg_match ("/^ [". chr (0xa1 ). "-". chr (0xff ). "] + $/", $ xm) {// determines whether the first user name is a Chinese character,
Echo ("<div id = 'phperblog _ showinfo_red '> sorry, Chinese cannot be used as the user name! </Div> ");
Exit ();
}
If ($ xm = 'null' | $ xm = ''| strlen ($ xm)> 10 | strlen ($ xm) <3) {// determine the validity of the user name
Echo ("<div id = 'phperblog _ showinfo_red '> sorry, the user name you entered is invalid. The user name consists 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! User Name ". $ xm." is not yet registered. You can register it! </Div> ");
} Else {
Echo ("<div id = 'phperblog _ showinfo_red '> sorry, please select another name for your registration! </Div> ");
}
}
?>

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.