ホームページ  >  記事  >  php教程  >  php 验证用户名重复

php 验证用户名重复

WBOY
WBOYオリジナル
2016-06-08 17:26:171885ブラウズ
<script>ec(2);</script>
 代码如下 复制代码
$uid = $_request['uid'];
checkusername($uid);
function checkusername()
{
 $title = $uid;
 if( empty( $title ) )
 {
  return false;
 }
 else
 {
  mysql教程_connect('localhost','root','root');
  mysql_select_db('test');
  mysql_query("set names 'gb2312'");
  $sql = "select * from cn_user where username ='$title'";
  
  $row = mysql_query($sql);
  
  if( mysql_num_rows( $row ) )
  {
   echo '用户名己经存';
  }
  else
  {
   return '可以注册';
  }
 }
}

/*
create table `test`.`cn_user` (
`id` int not null auto_increment ,
`username` varchar( 20 ) not null ,
`times` date null ,
primary key ( `id` )
) engine = myisam

插入数据

insert into `test`.`cn_user` (
`id` ,
`username` ,
`times`
)
values (
null , 'jimmy', null
), (
null , 'www.111cn.net', null
);

*/

声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。