This tutorial is a use of Ajax PHP after the user entered the user name, will send a request to the PHP program, and then query the data, to determine whether the user to register the user name is registered or there is duplicate, timely return information, in order to prevent users to fill out a large form of filling, The experience is not good if you suddenly provide a username that is not registered. This tutorial is specifically to solve this problem, can quickly tell you to register the user name can be registered.
ajax+php Tutorial Verifying user name Duplicate code instance
/*
This tutorial is a use of Ajax PHP after the user entered the user name, will send a request to the PHP program, and then query the data, to determine whether the user to register the user name is registered or there is duplicate, timely return information, in order to prevent users to fill out a large form of filling, The experience is not good if you suddenly provide a username that is not registered. This tutorial is specifically to solve this problem, can quickly tell you to register the user name can be registered.
*/
?>
ajax+php Verifying user name Duplicate code instance
Save the following code Tianjiang 13.php
checkusername ();
function Checkusername ()
{
$title = Trim ($_get[' title ');
if (empty ($title))
{
return false;
}
Else
{
MySQL tutorial _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 1;
}
Else
{
return null;
}
}
}
/*
CREATE TABLE ' Test '. ' Cn_user ' (
' id ' int not NULL auto_increment,
' username ' varchar (not NULL),
' Times ' date null,
Primary KEY (' ID ')
) engine = MyISAM
Inserting data
INSERT INTO ' test '. ' Cn_user ' (
' ID ',
' Username ',
' Times '
)
VALUES (
NULL, ' Jimmy ', null
), (
NULL, ' www.bKjia.c0m ', null
);
*/
?>
http://www.bkjia.com/PHPjc/630819.html www.bkjia.com true http://www.bkjia.com/PHPjc/630819.html techarticle This tutorial is a use of Ajax PHP after the user entered the user name, will send a request to the PHP program, and then query the data to determine whether the user to register the user name is registered or exist ...