欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

ajax jquery 異步表單驗(yàn)證示例代碼

 更新時(shí)間:2013年08月09日 17:14:54   作者:  
異步表單驗(yàn)證想必大家早已如雷貫耳,本文為大家詳細(xì)講述下ajax jquery實(shí)現(xiàn)異步表單驗(yàn)證,感興趣的朋友可以參考下
文件目錄:
 
html代碼:
復(fù)制代碼 代碼如下:

<html>
<head>
<title>異步表單驗(yàn)證</title>
<script type='text/javascript' src='jquery.js' ></script>
<script>
function checkname(){
//$("input[name='name']").val()
$.ajax({
type:"get",
url:'index.php',
data:"name="+$("input[name='name']").val(),
success:function(msg){
$("#show").append(msg);
}
});

}
</script>
</head>
<body>
<form name='form'>
<input name='name' type='text' onblur='checkname();'>
<span id='show'></span><br />
<input type='submit' name='submit' value='提交' />
</form>
</body>
</html>

php代碼:
復(fù)制代碼 代碼如下:

<?php
//進(jìn)行連接服務(wù)器
$link=mysql_connect('localhost','root','sanyue');
if(!$link){
die('連接失?。?.mysql_error());
}
//進(jìn)行連接數(shù)據(jù)庫(kù)
mysql_select_db('excour',$link);

// $name=$_GET['name'];
echo $name;
$sql="select name from user_info where name='$name'";

//執(zhí)行查詢(xún)語(yǔ)句
$result=mysql_query($sql);


if(mysql_num_rows($result) != 0){
echo "<font color='red'>名字太受歡迎,換一個(gè)吧</font>";
}else{
echo "<font color='blue'>成功</font>";
}

//進(jìn)行釋放查詢(xún)結(jié)果集
mysql_free_result($result);
//關(guān)閉數(shù)據(jù)庫(kù)連接
mysql_close($link);
?>

運(yùn)行結(jié)果示例:

相關(guān)文章

最新評(píng)論