目录
ajax用户注册程序
首页 后端开发 php教程 AJAX用户注册演示程序_PHP教程

AJAX用户注册演示程序_PHP教程

Jul 15, 2016 pm 01:22 PM
ajax doctype dtd e html public w3c 演示 用户注册 程序

用户注册演示程序

<! doctype html public "-//w3c//dtd html 4.0//en"
"http://www.w3.org/tr/rec-html140/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<title>ajax用户注册演示程序</title>
<script language="网页特效" type="text/网页特效">
<!--
//创建函数
function createxmlhttp() 
{
  var request;
  var browser = navigator.appname;
  //使用ie,则使用xmlhttp对象
  if(browser == "microsoft internet explorer") 
  {
    var arrversions = ["microsoft.xmlhttp", "msxml2.xmlhttp.4.0",
      "msxml2.xmlhttp.3.0", "msxml2.xmlhttp","msxml2.xmlhttp.5.0"];
    for (var i=0; i < arrversions.length; i++) 
    {
      try 
      {
 //从中找到一个支持的版本并建立xmlhttp对象
        request = new activexobject(arrversions[i]); 
        return request;
      } 
      catch (exception)
      {
        //忽略,继续
      }
    }
  }
  else
  {
    //否则返回一个xmlhttprequest对象
    request = new xmlhttprequest(); 
    if(request.overridemimetype)
    {
    request.overridemimetype(&#39;text/xml&#39;);
   }
    return request;
  }   
}
//全局xmlhttp对象实例变量
var http = createxmlhttp();
//发送请求
function chkuser()
{
  var url = "check.php教程";    //请求"checkusername" servlet
  var name = document.getelementbyid("username").value;   
  url += ("?username="+escape(name)+"&oprate=chkuser");
  http.open("get",url,true);
  http.onreadystatechange = processhttpresponse;
  http.send(null);
  return ;
}
//处理响应
function processhttpresponse()
{
  if(http.readystate == 4)
  {
    if(http.status == 200)
    {
     var xmldocument = http.responsexml;
     if(http.responsetext!="该用户名有效,可以使用!")
      {
 //返回的信息动态显示
      document.getelementbyid("showstr").style.display = "";
      document.getelementbyid("username").style.background= "#ff0000";
      document.getelementbyid("showstr").innertext = http.responsetext;
     }
      else
      {
      document.getelementbyid("username").style.background= "#ffffff";
      document.getelementbyid("showstr").style.display = "";
        document.getelementbyid("showstr").innertext = http.responsetext;
     }
    }
    else
    {
    alert("你所请求的页面发生异常,可能会影响你浏览该页的信息!");
    alert(http.status);
    }
  }
}
//检验输入密码
function chkpassword()
{
  var m=document.form1;
  if(m.password.value.length>20 || m.password.value.length<6 )
  {
    document.getelementbyid("passwordstr").style.display = "";
   document.getelementbyid("password").style.background= "#ff0000";
   document.getelementbyid("passwordstr").innertext = "对不起,密码必须为英文字母、数字或下划线,长度为6~20!";
   }
   else
   {
    document.getelementbyid("password").style.background= "#ffffff";
    document.getelementbyid("passwordstr").style.display = "none";
   }
}
//验证两次密码是否一致
function chkconfirmpassword()
{
   var m=document.form1;
  if (m.password.value != m.confirmpassword.value)
  {
   document.getelementbyid("confirmpasswordstr").style.display = "";
   document.getelementbyid("confirmpassword").style.background= "#ff0000";
   document.getelementbyid("confirmpasswordstr").innertext = "对不起,密码与重复密码不一致!";
  }
  else
  {
   document.getelementbyid("confirmpassword").style.background= "#ffffff";
   document.getelementbyid("confirmpasswordstr").style.display = "none";
  }
} 
//验证email是否有效
function chkemail()
{
   var m=document.form1;
   var email = m.email.value;  
   //正则表达式
  var regex = /^([a-za-z0-9_-])+@([a-za-z0-9_-])+(.[a-za-z0-9_-])+/;    
  var flag = regex.test(email);         
  if(!flag)    
  {
     document.getelementbyid("emailstr").style.display = "";
   document.getelementbyid("email").style.background= "#ff0000";
   document.getelementbyid("emailstr").innertext = "对不起,邮箱地址无效!";  
  }    
  else    
  { 
     document.getelementbyid("email").style.background= "#ffffff";
   document.getelementbyid("emailstr").style.display = "none";  
  }
   
}
//提交检查函数 
function submitcheck()
{
  var m=document.form1; 
  if(m.username.value.length==0)
  {
   alert("对不起,用户名必须为英文字母、数字或下划线,长度为5~20。");
   m.username.focus();
   return false;
  }
  if(m.password.value.length==0)
  {
   alert("对不起,密码必须为英文字母、数字或下划线,长度为5~20。");
   m.password.focus();
   return false;
  }
  if (m.password.value != m.confirmpassword.value)
  {
   alert("对不起,密码与重复密码不一致!");
   m.confirmpassword.focus();
   return false;
  } 
  if(m.email.value.length==0)
  {
   alert("对不起,邮箱地址不能为空!!");
   m.email.focus();
   return false; 
  }
  m.submit();
}
//--> 
</script>
<body >
<form name="form1" method="post" action="register.php">
<h3 id="ajax用户注册程序">ajax用户注册程序</h3>
<table align="center" width="500" border="1" >
  <tr>
    <td><font color="red">*</font></td>
    <td width="100">用户帐号:</td>
    <td><input type="text" name="username" maxlength="20" style="background=#ffffff" onblur="chkuser()"></td>
    <td><div id="showstr" style="background-color:#ff9900;display:none"></div></td>
  </tr>
  <tr>
    <td><font color="red">*</font></td>
    <td>用户密码:</td>
    <td align="left"><input type="password" name="password" maxlength="22" style="background=#ffffff" onblur="chkpassword()"/> </td>
    <td><div id="passwordstr" style="background-color:#ff9900;display:none"></div></td>
  </tr>
  <tr>
    <td><font color="red">*</font></td>
    <td>确认密码:</td>
    <td><input type="password" name="confirmpassword" maxlength="20" style="background=#ffffff" onblur="chkconfirmpassword()"/></td>
    <td><div id="confirmpasswordstr" style="background-color:#ff9900;display:none"></div></td>
  </tr>
  <tr>
    <td><font color="red">*</font></td>
    <td>email:</td>
    <td><input type="text" name="email" maxlength="100"  style="background=#ffffff" onblur="chkemail()"></td>
    <td><div id="emailstr" style="background-color:#ff9900;display:none"></div></td>
  </tr>
</table>
<div align="center"> 
  
   <input type="button" name="ok" value=" 确定 " onclick="submitcheck()">
   <input type="reset" name="reset" value=" 取消 ">
  </form>
</div>
</body>
</html>reg.php检测程序
<?php
header("content-type:text/html;charset=gb2312");
@mysql教程_connect(&#39;localhost&#39;,&#39;root&#39;,&#39;ebaeba&#39;) or die("数据库教程服务器连接失败");
@mysql_select_db("test") or die("数据库不存在或不可用");
 
$uname = $_get[&#39;username&#39;];
//下面进行数据库查询  查找是不是有这一个用户
//如果没有查找到这个用户名
 
$sql="select * from t1 where name=&#39;".$uname."&#39;";
$query=mysql_query($sql);
$row=mysql_fetch_object($query);
if(strlen($uname)<6||strlen($uname)>20)
{
   $msg="用户名必须是6至20个字符.";
}
else
{
 
   if($row==false)
   {
      $msg="该用户名有效,可以使用!";
   }
   else
   {
      $msg="对不起,此用户名已经存在,请更换用户名注册!";
   }
}
echo $msg ;
?>
登录后复制

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/447006.htmlTechArticle用户注册演示程序 ! doctype html public -//w3c//dtd html 4.0//enhttp://www.w3.org/tr/rec-html140/strict.dtdhtmlheadmeta http-equiv=content-type content=text/html; charset=gb2...
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

AI Hentai Generator

AI Hentai Generator

免费生成ai无尽的。

热门文章

R.E.P.O.能量晶体解释及其做什么(黄色晶体)
2 周前 By 尊渡假赌尊渡假赌尊渡假赌
仓库:如何复兴队友
4 周前 By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island冒险:如何获得巨型种子
4 周前 By 尊渡假赌尊渡假赌尊渡假赌

热工具

记事本++7.3.1

记事本++7.3.1

好用且免费的代码编辑器

SublimeText3汉化版

SublimeText3汉化版

中文版,非常好用

禅工作室 13.0.1

禅工作室 13.0.1

功能强大的PHP集成开发环境

Dreamweaver CS6

Dreamweaver CS6

视觉化网页开发工具

SublimeText3 Mac版

SublimeText3 Mac版

神级代码编辑软件(SublimeText3)

HTML 中的表格边框 HTML 中的表格边框 Sep 04, 2024 pm 04:49 PM

HTML 表格边框指南。在这里,我们以 HTML 中的表格边框为例,讨论定义表格边框的多种方法。

HTML 中的嵌套表 HTML 中的嵌套表 Sep 04, 2024 pm 04:49 PM

这是 HTML 中嵌套表的指南。这里我们讨论如何在表中创建表以及相应的示例。

HTML 左边距 HTML 左边距 Sep 04, 2024 pm 04:48 PM

HTML 左边距指南。在这里,我们讨论 HTML margin-left 的简要概述及其示例及其代码实现。

HTML 表格布局 HTML 表格布局 Sep 04, 2024 pm 04:54 PM

HTML 表格布局指南。在这里,我们详细讨论 HTML 表格布局的值以及示例和输出。

Bitget Wallet交易所怎么注册不了是什么原因 Bitget Wallet交易所怎么注册不了是什么原因 Sep 06, 2024 pm 03:34 PM

无法注册BitgetWallet交易所的原因有多种,包括账户限制、不支持的地区、网络问题、系统维护和技术故障。要注册BitgetWallet交易所,请访问官网、填写信息、同意条款、完成注册并验证身份。

在 HTML 中移动文本 在 HTML 中移动文本 Sep 04, 2024 pm 04:45 PM

HTML 中的文本移动指南。在这里我们讨论一下marquee标签如何使用语法和实现示例。

HTML 有序列表 HTML 有序列表 Sep 04, 2024 pm 04:43 PM

HTML 有序列表指南。在这里我们还分别讨论了 HTML 有序列表和类型的介绍以及它们的示例

DeepSeek官网入口及最新优惠活动一览 DeepSeek官网入口及最新优惠活动一览 Feb 19, 2025 pm 05:15 PM

DeepSeek 官网现推出多重优惠活动,为用户提供お得购物体验。新用户注册即可获得 10 美元优惠券,全场享受 15% 限时折扣。推荐好友还可赚取奖励,购物消费可累积积分兑换礼品。活动截止时间不同,详情请访问 DeepSeek 官网查询。

See all articles