php+jqueryajax邮箱地址无刷新验证实例_PHP教程
时间:2021-07-01 10:21:17
帮助过:5人阅读
要实现无刷新页面我们一般会用到ajax来实现,以前是使用最原始的js ajax验证现在常用的jquery ajax了只要简单的一句post即可解决了,下面我们看实例
index.php页面
代码如下 |
|
php jquery check username ajax检查帐号唯一性
Username:
|
php验证页面,此页面接收到jquery ajax post过来的数据进行验证并返回值
代码如下 |
|
# 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 "非常好,MYSQL连接成功了!";
//} else {
//echo "不好意思,失败了!";
//}
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通过检查
$query = "SELECT email FROM user WHERE email = '$username' LIMIT 1";
$result = mysql_query( $query );
$num = mysql_num_rows($result);
echo $num;
}
else
{
echo "1";//不能注册
}
?>
|
http://www.bkjia.com/PHPjc/632749.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/632749.htmlTechArticle要实现无刷新页面我们一般会用到ajax来实现,以前是使用最原始的js ajax验证现在常用的jquery ajax了只要简单的一句post即可解决了,下面我们...