当前位置:Gxlcms > PHP教程 > phpajax注册验证用户名是否存在代码_PHP教程

phpajax注册验证用户名是否存在代码_PHP教程

时间:2021-07-01 10:21:17 帮助过:3人阅读

php ajax注册验证用户名是否存在代码 这是注册程序是一款当用户输入完用户名是,就会自动去数据库中查询用户要注册的用户名是否己经被注册了,如果是返回提示否则提示可以注册。

php教程 ajax注册验证用户名是否存在代码
这是注册程序是一款当用户输入完用户名是,就会自动去数据库教程中查询用户要注册的用户名是否己经被注册了,如果是返回提示否则提示可以注册。
conn.php文件











$q=$_get["q"];
$q = urldecode($q);

if (strlen($q) > 0)
{
$conn = @mysql教程_connect("localhost","root","1010") or die ("mysql连接错误");
mysql_select_db("xin",$conn);
mysql_query("set names 'utf8'");

$sql = "select username from message where username = '$q'";
$query = mysql_query($sql);
@$row = mysql_fetch_array($query);

if(!empty($row['username']))
{
$response = "已经被注册!";
}else
{
$response = "恭喜!可以注册!";
}

echo $response;
}

?>

数据库
drop database if exists `xin`;
create database `xin` /*!40100 default character set utf8 */;
use `xin`;


create table `message` (
`id` int(11) not null auto_increment,
`username` varchar(20) default null,
primary key (`id`)
) engine=innodb auto_increment=2 default charset=utf8;

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/632060.htmlTechArticlephp ajax注册验证用户名是否存在代码这是注册程序是一款当用户输入完用户名是,就会自动去数据库中查询用户要注册的用户名是否己经被注...

人气教程排行