Home > php教程 > php手册 > [原创]ajax 实现用户注册功能教程三

[原创]ajax 实现用户注册功能教程三

WBOY
Release: 2016-06-13 10:13:08
Original
1112 people have browsed it

//[原创]ajax 实现用户注册功能教程三

本教程由本站原创,转载请注明来处

作者:www.drise.cn

邮箱:drise@163.com

QQ:271728967

//

现在到了第三步,我们来写type.php文件,这个文件的作用是判断用户名是否存在,再然后数据给用户.

header("Content-type:text/html;charset=gb2312");//为了不让其出现乱码所以把文档编码设置为gb2312
$xm=Strreplace(isset($_GET['txt'])?$_GET['txt']:'null');//取得用户名
if(preg_match("/^[".chr(0xa1)."-".chr(0xff)."]+$/", $xm)){//判断用户名第一个是否为汉字,
  echo("

对不起,不能使用中文作为用户名!
");
  exit();
  }
if($xm=='null' || $xm=='' || strlen($xm)>10 || strlen($xm)  echo("
对不起,你输入的用户名不合法,用户由3-10Aa_zZ及数字组成!
");
 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("
恭喜你!用户名".$xm."还未注册,你可以注册!
");
 }else{
  echo("
对不起,用户己注册请选择其它名称!
");
 }
}
?>
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template