环境: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,然后再进行另一条记录的修改。
谢谢这里的朋友!
代码如下:
<?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,然后再进行另一条记录的修改。
谢谢这里的朋友!
echo "*".$_SESSION['srch_ordowner']."*"."<br>"; 结果是什么?
只是点击链接后,echo "*".$_SESSION['srch_ordowner']."*"."<br>";的结果为: **,中间什么也没有出现。
tst.php里的是什么东西? 一点它全部session 没了?
点击它,在当前页面中建立的session没了。别的页面传过来的session还在。
echo $_SESSION["srch_ordowner"]; //here, show what?
?>
<?php session_start();
echo $_SESSION["srch_ordowner"]; //show abc
?>
这时点击“列表”,
<?php session_start();
echo $_SESSION["srch_ordowner"]; // show none,不显示了
?>
<?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>