To achieve a non-refresh page, we usually use ajax to achieve it. In the past, we used the most primitive js ajax for verification. Now we use the commonly used jquery ajax. Just a simple post can solve the problem. Let's look at the example below
index .php page
The code is as follows
|
Copy code
|
||||
|
The code is as follows | Copy code |
<🎜># FileName="Connection_php_mysql.htm" # Type="MYSQL" # HTTP="true" $hostname_lr = "localhost"; $database_lr = "ordersiliconebracelets"; $username_lr = "root"; $password_lr = ""; $lr = mysql_pconnect($hostname_lr, $username_lr, $password_lr) or trigger_error(mysql_error(),E_USER_ERROR); mysql_query("set names utf8;"); //if ($lr) { //echo "Very good, MYSQL connection successful!"; //} else { //echo "Sorry, failed!"; //} mysql_select_db($database_lr, $lr);<🎜> <🎜>// $username = trim(strtolower($_POST['username'])); $username = mysql_escape_string($username);<🎜> <🎜>if (eregi("^[_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,3}$ ",$username)) { //email passed the check $query = "SELECT email FROM user WHERE email = '$username' LIMIT 1"; $result = mysql_query( $query ); $num = mysql_num_rows($result); echo $num; } else<🎜> <🎜>{ echo "1";//Cannot register<🎜> <🎜>} ?> |