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