php代码如下:<?php
$hospitalid=trim($_REQUEST["hospitalusername"]);
$password=trim($_REQUEST["hospitalpassword"]);
$remind="";if($hospitalid==""||$password==""){
$remind="用户名或密码不能为空!";
}
else{
$con = mysql_connect("localhost","","");
if (!$con)
{
die('Could not connect: '.mysql_error());
}
mysql_select_db("sslee_f", $con);
//mysql_query("set names 'gb1312'");
$sql="SELECT * FROM phomezx_ecms_hospital where hospitalid='$hospitalid';";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result))
{
$t_password =trim($row["hospitalpassword"]);
$t_hospitalname =trim($row["hospitalname"]);
}
mysql_close($con);
if($password==$t_password){
header('Location: hospitalusercenter.php');
}
else{
$remind="错误的用户名或密码!";
}
}
?>$sql输出:SELECT * FROM phomezx_ecms_hospital where hospitalid='yoong'; 是没错的,在mysql数据库检索也是有结果的。页面字符集设置如下:<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
mysql数据库字符集utf8_unicode_ci,数据表字符集gbk_chinese_ci,hospitalid字段字符集gb2312_chinese_ci。数据库里英文和数字显示没错,但是中文是?????。php页面本地测试的时候用的是odbc,通过了;然后改成mysql的上传到服务器,运行的时候提示“用户名或密码错误”,所以猜测是字符集的问题,加上了注释掉的一行还是不行。
本人新手,用php不到一周,求高手指点!
$hospitalid=trim($_REQUEST["hospitalusername"]);
$password=trim($_REQUEST["hospitalpassword"]);
$remind="";if($hospitalid==""||$password==""){
$remind="用户名或密码不能为空!";
}
else{
$con = mysql_connect("localhost","","");
if (!$con)
{
die('Could not connect: '.mysql_error());
}
mysql_select_db("sslee_f", $con);
//mysql_query("set names 'gb1312'");
$sql="SELECT * FROM phomezx_ecms_hospital where hospitalid='$hospitalid';";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result))
{
$t_password =trim($row["hospitalpassword"]);
$t_hospitalname =trim($row["hospitalname"]);
}
mysql_close($con);
if($password==$t_password){
header('Location: hospitalusercenter.php');
}
else{
$remind="错误的用户名或密码!";
}
}
?>$sql输出:SELECT * FROM phomezx_ecms_hospital where hospitalid='yoong'; 是没错的,在mysql数据库检索也是有结果的。页面字符集设置如下:<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
mysql数据库字符集utf8_unicode_ci,数据表字符集gbk_chinese_ci,hospitalid字段字符集gb2312_chinese_ci。数据库里英文和数字显示没错,但是中文是?????。php页面本地测试的时候用的是odbc,通过了;然后改成mysql的上传到服务器,运行的时候提示“用户名或密码错误”,所以猜测是字符集的问题,加上了注释掉的一行还是不行。
本人新手,用php不到一周,求高手指点!
$password=trim($_REQUEST["hospitalpassword"]);
这样写本来就很奇怪
$result = mysql_query($sql);
while($row = mysql_fetch_array($result))
{
$t_password =trim($row["hospitalpassword"]);
$t_hospitalname =trim($row["hospitalname"]);
}
echo $t_hospitalname; //在这里检查口令是否正确
mysql_close($con);