PHP Ajax Registration Verifying user name existence Code _php tutorial

Source: Internet
Author: User
PHP Ajax Registration Verify that the user name exists code this is the registration program is a user after the user name is entered, it will automatically go to the database to query the user to register the user name has been registered, if it is returned prompt can be registered.

PHP Tutorial Ajax Registration Verifying user name Presence code
This is a registration program is a when the user entered the user name is, will automatically go to the database tutorial to query the user to register the user name has been registered, if it is returned prompt otherwise prompt 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 = "has been registered! ";
}else
{
$response = "Congratulations! 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 (one) not NULL auto_increment,
' username ' varchar default NULL,
Primary KEY (' ID ')
) Engine=innodb auto_increment=2 default Charset=utf8;

http://www.bkjia.com/PHPjc/632060.html www.bkjia.com true http://www.bkjia.com/PHPjc/632060.html techarticle PHP Ajax Registration Verify that the user name exists code this is a registration process when the user has entered the user name is, will automatically go to the database to query the user to register the user name has been the note ...

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