开发环境是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>密 码</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")这句总是为假,我也不知道是为什么了还希望高手帮我看看
<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>密 码</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")这句总是为假,我也不知道是为什么了还希望高手帮我看看
解决方案 »
- PHP可以像.net那样调试吗?
- 博客文章问题...如何让别人复制我的文章后自动的在内存里插入转载说明?
- 不明白这段代码alert()执行两次
- php通过pdo调用存储过程,如何使用output返回值
- 把php中的值在js的alert对话框中显示
- 从编辑器里面传给数据库的数据中回车换行变成了什么字符?
- 请教高手
- 正则~ 只能由数字、字母或"-"(只能在中间) 组成的~~ help
- PHP 删除文件
- 急。 我在apache环境下写的php可以运行,可以将数据库数据输出到网页上。 把文件放到IIS服务器下面。。什么东西都不出了。。什么原因?
- 关于php配置支持<? ?>的方法
- session有时会丢失
看看真的输出 -OK-吗?
,希望有帮助