ajax+php Verifying user name Duplicate code instance _php Tutorial

Source: Internet
Author: User
Tags mysql tutorial
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







Enter user name



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 ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.