php ajax registration verification code exists for username This is a registration program. When the user enters the user name, it will automatically go to the database to check whether the user name that the user wants to register has been registered. If so, it will return a prompt, otherwise it will prompt that the user can register.
php tutorial ajax registration verification code for username existence
This is a registration program. When the user enters the user name, it will automatically go to the database tutorial to check whether the user name that the user wants to register has been registered. If so, it will return a prompt, otherwise it will prompt that the user can register.
conn.php file
$q=$_get["q"];
$q = urldecode($q);if (strlen($q) > 0)
{
$conn = @mysql tutorial_connect("localhost","root","1010") or die ("mysql connection error");
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 = "Already registered!";
}else
{
$response = "Congratulations! You can register!";
}
echo $response;
}?>
Database
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;