<?php
require_once("inc/xajax.inc.php");
$xajax = new xajax("inc/login.php");
$xajax->registerFunction("processForm");
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<link href="https://blogbeta.blueidea.com/css/style.css" _fcksavedurl=""https://blogbeta.blueidea.com/css/style.css"" type="text/css">
<title>无标题文档</title>
<?php $xajax->printJavascrīpt('inc/'); ?>
<scrīpt type="text/javascrīpt">
function submitSignup()
{
xajax.$('submitButton').disabled=true;
xajax.$('submitButton').value="http://blogbeta.blueidea.com/wait...";
xajax_processForm(xajax.getFormValues("signupForm"));
return false;
}
</scrīpt>
</head>
<body><form action="javascrīpt:void(null);" ōnSubmit="submitSignup();">
<div>
<div>用 户 登 陆</div>
<div>
<table cellspacing="0" cellpadding="5">
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>用户名:</td>
<td><input type="text" />
*</td>
</tr>
<tr>
<td>密码:</td>
<td><input type="password" />
*</td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="提交" />
<input type="reset" value="重置" /></td>
</tr>
</table>
</div>
</div>
</form>
</body>
</html>
4、inc/login.php 登陆用的处理文件
复制代码 代码如下:
<?php
define ('XAJAX_DEFAULT_CHAR_ENCODING', 'gb2312' );
require_once("xajax.inc.php");
require_once("function.php");
$xajax = new xajax();
$xajax->registerFunction("processForm");
function processForm($aFormValues)
{
$objResponse = new xajaxResponse();
require_once("conn.php");
$usr=$aFormValues['usr'];
$email=$aFormValues['email'];
$pwd=$aFormValues['pwd'];
$pw=Md5($pwd);
$errmsg="";
//要过滤的非法字符
$ArrFiltrate=array("'",";","union");
foreach($aFormValues as $key=>$value){
if (FunStringExist($value,$ArrFiltrate)){
$objResponse->addAlert("输入的信息含有非法字符\"' ; union!\"");
$objResponse->addAssign("submitButton","value","继续");
$objResponse->addAssign("submitButton","disabled",false);
return $objResponse;
}
}
if (trim($usr) == "")
{
$errmsg.="请输入用户名!\n";
}
if (trim($pwd) == "")
{
$errmsg.="请输入密码!\n";
}
$sql="select * from zl_usr where zl_usr='$usr' and zl_pwd='$pw'";
$result=mysql_query($sql,$db);
if(!$myrow=mysql_fetch_array($result)){
$errmsg.="用户名不存在,或密码错误!\n";
}
if ($errmsg=="")
{
$sForm = "登陆成功";
$objResponse->addAssign("formDiv","innerHTML",$sForm);
}
else
{
$objResponse->addAlert($errmsg);
$objResponse->addAssign("submitButton","value","继续");
$objResponse->addAssign("submitButton","disabled",false);
}
return $objResponse;
}
$xajax->processRequests();
?>
登陆于注册原理差不多,就不废话了:)
另外下面是两个用到的文件代码 conn.php function.php
conn.php
复制代码 代码如下: