PHP+ajax注册进度条验证代码
来源:互联网 发布:C语言unlink函数 编辑:程序博客网 时间:2024/05/26 05:52
ajax.php页面
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<script type="text/javascript">
var xmlHttp;
function S_xmlhttprequest(){
if(window.ActiveXObject){
xmlHttp=new ActiveXObject('Microsoft.XMLHTTP');
}else if(window.XMLHttpRequest){
xmlHttp=new XMLHttpRequest();
}
}
function funphp100(username){
var username=document.reg.username.value;
S_xmlhttprequest();
xmlHttp.open("GET","checkuserreg.php?id="+username,true);
xmlHttp.onreadystatechange=byphp;
//确定发送请求方式,URL,及是否同步执行下段代码
xmlHttp.send(null);
}
//处理返回信息的函数
function byphp(){
if(xmlHttp.readyState==1){
document.getElementById('check1').innerHTML="loading........"; //可以调用图片
}
if(xmlHttp.readyState==4){ //判断对象状态
if(xmlHttp.status==200){ //信息已成功返回,开始处理信息
var byphp100=xmlHttp.responseText;
document.getElementById('check1').innerHTML=byphp100;
}
}
}
/*可以用相应的js控件验证*/
/*function check(){ //用户名为空的时候
if(document.reg.username.value==""){
document.getElementById('check').innerHTML=" <font color=red>用户名不能为空!</font>";
document.reg.username.focus();
return false;
}
if(document.getElementById('check').innerHTML==" <font color=red>The number is registed</font>"){ //用户名已被注册的时候(<font color=red>The number is registed</font>是AJAX返回回来的)
document.reg.username.focus();
return false;
}
if(document.reg.userpwd.value==""){ //密码为空的时候
document.getElementById('pwd').innerHTML=" <font color=red>用户密码不能为空!</font>";
document.reg.userpwd.focus();
return false;
}
if(document.reg.userpwd.value.length<6){ //密码长度错误的时候
document.getElementById('pwd').innerHTML=" <font color=red>密码长度不能小于6位!</font>";
document.reg.userpwd.focus();
return false;
}
if (document.reg.reuserpwd.value==""){ //没有再次输入密码的时候
document.getElementById('repwd').innerHTML=" <font color=red>请再输入一次密码!</font>";
document.reg.reuserpwd.focus();
return false;
}
if(document.reg.userpwd.value!=document.reg.reuserpwd.value){ //再次输入密码不正确的时候
document.getElementById('repwd').innerHTML=" <font color=red>两次输入的密码不一致!</font>";
document.reg.reuserpwd.focus();
return false;
}
return true; //上面的验证都通过则return true,页面信息将被POST到checkuserreg.php进行处理。
}*/
</script>
<body>
<form method="post" name="reg" id="reg" action="" onsubmit="return funphp100()">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td class="td1">登陆帐号:</td>
<td>
<input name="username" type="text" id="username" size="20" maxlength="20" class="textipt" onBlur="funphp100()"/>
<span id="check" class="msg">4-16个字符,英文小写、汉字、数字。</span></td>
</tr>
<tr>
<td class="td1">登录密码:</td>
<td><input name="userpwd" type="password" id="userpwd" size="30" maxlength="30" class="textipt"/>
<span class="msg" id="pwd">密码字母有大小写之分,英文、数字。</span></td>
</tr>
<tr>
<td class="td1">确认密码:</td>
<td><input name="reuserpwd" type="password" id="reuserpwd" size="30" maxlength="30" class="textipt"/> <span class="msg" id="repwd">请再次输入登录密码。</span></td>
</tr>
<tr>
<td colspan="2" align="left" valign="middle" height="50">
<span id="check1" class="msg">qqqqq</span>
<input name="submit" type="submit" value="提交" /></td>
</tr>
</table>
</form>
</body>
</html>
checkuserreg.php 页面
<?php
header("Content-type: text/html;charset=utf-8");
if($_GET['id'])
{
sleep(2);
$conn=mysql_connect("localhost","root","") ;
mysql_select_db("2012",$conn) ;
$username=$_GET['id'];//获取注册名
$sql=mysql_query("select * from db_admin where username='$username'");
if(is_array(mysql_fetch_row($sql))){
echo" <font color=red>The number is registed</font>";
}else{
echo" <font color=red>恭喜,此用户名可以注册!</font>";
}
}
?>
- PHP+ajax注册进度条验证代码
- php+ajax注册验证
- 基于php+ajax的注册用户名验证
- PHP实现Ajax注册用户名验证---示例
- php+ajax 注册验证用户名是否存在实例
- ajax+javascript+php实现注册用户名无刷新验证
- php实现Ajax带有验证码的登陆注册功能
- php 配合 ajax 进度条
- ajax 注册表单验证
- ajax注册验证
- Ajax注册验证
- jquery ajax验证注册
- ajax注册验证
- 手机注册获取验证码的PHP代码
- 手机注册获取验证码的PHP代码
- php+mysql用户注册与验证页面代码
- php注册+验证码
- jquery中用$.ajax实现注册(html、jquery、php、接口文档)、ajax验证用户提交数据
- Sizeof与Strlen的区别
- win7中的硬盘NTFS格式转成FAT32,不会丢失数据
- Metro学习笔记+心得+体会(一)
- Linux中select函数的使用 select() Linux linux函数 select
- 一些实用的小技术,不定时更新^_^
- PHP+ajax注册进度条验证代码
- 关于exec的例子
- SetWindowsHookEx
- javascript+css好多网站用的选星星实现打分功能的函数
- 第四步:串口(基于飞凌6410的开发板)
- javascript笔记
- DLL(Dynamic Link Libraries)专题
- 构建自己的Android代码托管服务器
- VBA中Option的四种用法