<?php
require("includes/class/xajax/xajax.inc.php");
function is_reg($username)
{
$username=iconv("utf-8", "gb2312", $username);
$conn = new mysqli('localhost','root','wowangle','mysite');
$conn->query("set names gb2312");
$rs = $conn->query("select * from xf_users where us_username='$username'");
if($rs->num_rows > 0)
{
$is_reg = "用户名称已被注册!";
}
else
{
$is_reg = "可以注册!";
}
$objResponse = new xajaxResponse();
$objResponse->setCharEncoding("GB2312");
$objResponse->addAssign("div1","innerHTML", $is_reg);
return $objResponse->getXML();
}
$xajax = new xajax();
$xajax->registerFunction("is_reg");
$xajax->processRequests();
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>title</title>
<?php $xajax->printJavascript("includes/class/xajax"); ?>
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#FF9966" vlink="#FF9966" alink="#FFCC99">
<form id="form1" name="form1" method="post" action="">
<input name="username" type="text" id="username" onChange="xajax_is_reg(document.getElementById('username').value);" /><div id="div1"> </div>
</form>
</body>
</html>
|