First create an Ajax class (Ajax Class)
Then create a new file form.html
--------------------------form.html----------------------------
Copy CodeThe code is as follows:
Finally, create a new PHP file form.php
--------------------------form.html----------------------------
Copy CodeThe code is as follows:
Header ("content-type:text/html;charset=gb2312"); Set character sets
$mysqli = new Mysqli ("localhost", "root", "123", "Demo"); Open Demo Database
$result = $mysqli->query ("select * from Zhanghao where name= ' {$_post[" username "]} ');
if ($result->num_rows > 0) {//Determine if the data is queried
echo "User {$_post[" username "} already exists! ";
}else{
echo "User {$_post[" username "} can be registered";
}
?>
Open form.html appears in the browser:
Note: A table "Zhanghao" needs to be established in the MySQL database in advance
If you enter a name that already exists, the following prompt appears:
If you enter a name that does not exist, the following prompt appears:
http://www.bkjia.com/PHPjc/324729.html www.bkjia.com true http://www.bkjia.com/PHPjc/324729.html techarticle first create an Ajax class (Ajax Class) and then create a new file form.html--------------------------form.html----------------------------Copy code code as follows : Script src= "Ajax ...."