环境:PHP5.1.6,apache2.2.3 (appserv2.5.7)
代码如下:
<?php session_start(); ?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body topmargin="0" leftmargin="3" bottommargin="0">
<a href= "tst.php" >列表</a>
<?php
$conn=mysql_connect("localhost","root","abc") or die("数据库服务器连接错误".mysql_error());
mysql_select_db("osc",$conn) or die("数据库访问错误".mysql_error());
$srch_ordowner = $_POST[srch_ordowner];
if($srch_ordowner == "")$srch_ordowner = $_SESSION["srch_ordowner"];
else $_SESSION['srch_ordowner'] = $srch_ordowner;
$wheres = "where orderowner = '".$_SESSION['srch_ordowner']."'";
$sqlstr1 = "select * from oscorder ".$wheres;
$sql1=mysql_query($sqlstr1,$conn);
$info1=mysql_fetch_array($sql1);
echo "*".$_SESSION['srch_ordowner']."*"."<br>"; 
echo $sqlstr1."<br>";    
?>
<form name="form1" method="post" action="tst.php">
<input  name="srch_ordowner"  value="<?php echo $_SESSION["srch_ordowner"];?>" />
<input type="submit" value="查询" />
</form>
</body>
</html>
点击超链接“列表”时,$_SESSION['srch_ordowner']值就没有了。
请问有什么办法保留住吗?
我的目的是这样的:
这个页面叫A,会列出一些记录,然后点击一条记录就进入记录修改页面B。在页面B中有一个链接“列表”,点一下就回到了页面A,然后再进行另一条记录的修改。
谢谢这里的朋友!

解决方案 »

  1.   

    点击进入另外的页面 session的值不会没有
    echo "*".$_SESSION['srch_ordowner']."*"."<br>";  结果是什么?
      

  2.   

    输入001,点击‘查询’的时候,echo 001是正常的。
    只是点击链接后,echo "*".$_SESSION['srch_ordowner']."*"."<br>";的结果为: **,中间什么也没有出现。
      

  3.   

    可能你的 php.ini 里配配有问题,自动清缓冲了。
      

  4.   

    别的页面传过来的session会一直保留着呢。
      

  5.   


    tst.php里的是什么东西? 一点它全部session 没了?
      

  6.   

    tst.php就是上面的那个页面。
    点击它,在当前页面中建立的session没了。别的页面传过来的session还在。
      

  7.   

    <?php session_start();
    echo $_SESSION["srch_ordowner"]; //here, show what?
    ?>
      

  8.   

    如果输入abc 点击查询后,
    <?php session_start();
    echo $_SESSION["srch_ordowner"]; //show abc
    ?>
    这时点击“列表”,
    <?php session_start();
    echo $_SESSION["srch_ordowner"]; // show none,不显示了
    ?>
      

  9.   

    我现在把tst.php这个页面简化了一下(如下):输入一个值abc,多次点击查询,输入框中abc值都在的。如果这时点击‘列表’(列表对应的页面就是本页面),值就没了。
    <?php session_start();?>
    <html><head><meta http-equiv="Content-Type" content=" text/html; charset=utf-8"></head>
    <body topmargin="0" leftmargin="3" bottommargin="0">
    <a href= "/myosc/tst.php" >列表</a>
    <?php
    $mytst = $_POST[mytt];
    if($mytst == "" || $mytst == null){$mytst = $_SESSION["mytst"];}
    else {$_SESSION["mytst"] = $mytst;}
    ?>
    <form name="form1" method="post" action="tst.php">
    制單人 <input name="mytt"  id="mytt" value="<?php echo $mytst;?>" >
    <input type="submit" value="查询" />
    </form>
    </body></html>