代码如下 | 复制代码 |
$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.jquerycn.cn', null ); */ |
php用户注册重复_php 验证用户名重复
最新推荐文章于 2021-08-05 14:15:09 发布
本文介绍如何在PHP中实现用户注册时验证用户名是否已存在。通过连接数据库,查询用户名是否存在,确保每个注册的用户都有唯一的用户名。
摘要由CSDN通过智能技术生成