开发环境是zend studio 7.0,apache2.2+php5.2+mysql5.1一开始没考虑中文乱码的问题,等程序逻辑实现后才想起来,本来一切都好的,我在改变了PHP和HTML文件的存储编码格式为UTF-8后就出了个很怪的问题。。!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html>
<head>
<title>管理员登陆界面</title>
<script type="text/javascript" language="javascript" src="JS/ajax.js"></script>

<script type="text/javascript" language="javascript">
function check(){
var checkform=document.forms[0];
//alert(checkform.username.value);
//alert(checkform.password.value);
if(checkform.username.value==''||checkform.password.value==''){
alert("用户名或密码不能为空!");
}else{
var par="username="+checkform.username.value+"&"+"password="+checkform.password.value;
//alert(par);
sendRequest("post","adminLogin.php","true",test,par,"text");
}
}
function test(result){
alert(result);
if(result=="OK"){
alert("登陆成功");
location.href="adminManager.php";
}else{
//alert(result);
}
}
</script>
</head>
<body>
<form action="adminManager.php" method="get">
<table>
<tr>
<td>用户名:</td>
<td><input type="text" name="username" /></td>
</tr>
<tr>
<td>密&nbsp;&nbsp;码</td>
<td><input type="password" name="password" /></td>
</tr>
<tr>
<td align="right"><input type="button" value="确认" name="submit" onclick="check()" /></td>
<td align="center"><input type="reset" value="重置" name="reset" /></td>
</tr>
</table>
</form>
</body>
</html>adminLogin.php<?php
require '../commons/noCache.php';
require '../commons/Constants.php';
require '../dataBase/db_mysql.php';
require 'user.php';

$username=$_POST["username"];
$password=$_POST["password"];
$connDB=new DB(DB_SERVER,DB_SERVER_USERNAME,DB_SERVER_PASSWORD,DB_DATABASE);
$conn=$connDB->connect();
$sql="select * from admininfo where username='$username' and password='$password'";
$result=mysql_query($sql,$conn);
$info=mysql_fetch_row($result);
if($info){
session_start();
$user=new User($username,$password);
$_SESSION["user"]=$user;
echo "OK";
}else{
echo "用户名或密码错误!!";
}

?>大家看到了我的服务器返回的字段是OK,页面的result接收到了这个responseText得到的结果也是OK,但是if(result=="OK")这句总是为假,我也不知道是为什么了还希望高手帮我看看