<!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>
<body>
<?php
$username=$_REQUEST["username"];
$password=$_REQUEST["password"];
$con=mysql_connect("localhost","root","root");
if(!$con){
die("连接失败!");
}
mysql_select_db("test",$con);
mysql_query("insert into user(username,password) values ('".$username."','".$password."');");
mysql_close($con);
?>
<script>
alert("注册成功");
window.location.href="xajaxreg.php" rel="external nofollow" ;
</script>
</body>
</html>
<?php
include 'xajax_core/xajax.inc.php';
$xajax=new xajax();
//首先在xajax声明一个check函数
$xajax->registerFunction("check");
//这个check函数需要前台传来用户名username
function check($username){
$orps=new xajaxResponse();
//连接数据库,看看用没有这个用户名
$con=mysql_connect("localhost","root","root");
if(!$con){
die("连接失败!");
}
mysql_select_db("test",$con);
$dbusername=null;
$result=mysql_query("select * from user where username='".$username."';");
while($row=mysql_fetch_array($result)){
$dbusername=$row["username"];
}
//如果没有,根本不可能查出数据,对dbusername赋值的,所以dbusername还是为空的
if(is_null($dbusername)){
//弹窗,把id为submitbtn的提交按钮disabled属性清理掉,解锁disabled
$orps->alert("恭喜,该用户名未被占用,可以注册");
$orps->clear("submitbtn","disabled");
}
else{
//否则弹窗之后为submitbtn上锁,加上disabled属性
$orps->alert("该用户名已被占用,请更换被的用户名");
$orps->assign("submitbtn","disabled","disabled");
}
//人走带门,然后是三个xajax的指定动作
mysql_close($con);
return $orps;
}
$xajax->processRequest();
$xajax->printJavascript();
?>
<!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>
<body>
用户注册
<!--为表单上个onsubmit属性,是因为但用户点击提交按钮的时候,跑完这个check()函数再提交这个表单-->
<form action="xajxregsuc.php" method="post" onsubmit="return check()">
<!--但用户名的输入框失去焦点时,也就是用户输入完成,光标离开这个输入框的时候,马上调用xajax中的check函数,带过去的值就是本输入框的内容-->
用户名:<input type="text" name="username" onblur="xajax_check(this.value);" /><br />
密码:<input type="password" name="password" id="password" /><br />
<!--确认密码这里调用下面的javascript检查即可-->
请再次输入密码:<input type="password" name="passwordconfirm" id="passwordconfirm" onchange="check()"/><br />
<input type="submit" id="submitbtn" value="注册" disabled />
</form>
</body>
</html>
<script>
function check() {
var check = false;
var password = document.getElementById("password").value;
var pwdc = document.getElementById("passwordconfirm").value;
if (password != pwdc) {
alert("两次输入密码不一致");
check = false;
} else {
check = true;
}
return check;
}
</script>
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有