为什么用session传值为空?
member_login_do.php
<html>
<?php
/* 会员登陆处理页 */
require_once("../conn/Conn_DB.php"); //包含数据库链接文件
if( $_POST["txt_username"]!= "" && $_POST["txt_pwd"]!= "" )
{
$name = $_POST["txt_username"]; //获取提交的用户名
$pwd = $_POST["txt_pwd"]; //获取提交的密码
$str = "select * from Member_Info where M_Name = '$name' and M_Password = '$pwd'"; //查询语句
$result = mysql_query($str); //执行SQL语句
if( mysql_num_rows($result) >0 ) //查看返回的查询结果行数
{
session_id(SID);
session_start(); //登陆成功,设置SESSION值
$_SESSION['member'] = $_POST['txt_username'];
//session_write_close();
echo "<script> window.location.href='../member_info.php';</script>";
//exit(0);
}
else
{
echo "<script>alert('用户名或密码错误!');window.location.href='../member_login.php'</script>";
}
}
else
{
echo "<script>alert('请输入用户名和密码!');window.location.href='../member_login.php'</script>";
}
?>
</html>
[解决办法]
if( mysql_num_rows($result) >0 ) //查看返回的查询结果行数
{
exit; //进入这里了么
..................
你先搞清楚是在 member_info.php 跳转到 member_login.php 文件的还是在之前就跳转了。