Home >Backend Development >PHP Tutorial >PHP+ajax user registration to verify whether the user exists (php mysql complete example)_PHP tutorial
php+ajax user registration to verify whether the user exists (php mysql complete example) This is a complete user registration example program of php+mysql+ajax. It can detect whether the user name has been registered, which can enhance the user experience. After you fill in the user name, it will provide you with all currently registered users. Already registered.
php tutorial + ajax user registration to verify whether the user exists (php mysql tutorial complete example)
This is a complete user registration example program of php+mysql+ajax. It can detect whether the user name has been registered, which can enhance the user experience. After you fill in the user name, it will provide you with all current registrations. Whether the user has been registered.
This program includes three files
reg.html User registration html page
reg.php php processing code
conn.php database tutorial connection file
reg.html code
php+ajax user registration to verify whether the user exists (php mysql complete instance)
reg.php file
include("conn.php");
$name=$_get['name'];
$name=urldecode($name);if(strlen($name)>0){
$sql="select username from registration where username = '$name'";
$result=mysql_query($sql);
$row=mysql_fetch_array($result);
if($_get['act'] == 'reg'){
if(!empty($row['username'])){ //As long as the registered user name is kaixin, the registration page will prompt in red font that the user has been registered!
echo 'no';
}else{
echo 'yes';
}
}
}
?>
conn.php database file
/* created on 12:08:25 pm*/
$conn=@mysql_connect("localhost","root","")or die("bKjia.c0m prompts you: connection failed!");
mysql_select_db("reg",$conn);
mysql_query("set names 'gbk'");
?>
registration data table structure
--phpmyadmin sql dump
-- version 2.11.2.1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generated date: May 20, 2009 05:29
-- Server version: 5.0.45
-- php version: 5.2.5
set sql_mode="no_auto_value_on_zero";
--
-- Database: `reg`
--
-------------------------------------------------- ----------
--
-- Table structure `registration` phpmyadmin imports data
--
create table `registration` (
`id` tinyint(6) not null auto_increment,
`username` varchar(14) not null comment 'Registered username',
`userpwd` varchar(14) not null comment 'Registration password',
primary key (`id`)
) engine=innodb default charset=gb2312 auto_increment=6 ;--
--Export data in the table `registration`
--
insert into `registration` (`id`, `username`, `userpwd`) values
(1, 'admin', 'admin888'),
(2, 'lyn', 'bKjia.c0m'),
(3, 'xiaot', 'xiaot'),
(4, 'xiaoe', 'xiaoe'),
(5, 'I love www.bKjia.c0m', '5201314110');