会话在一页上有效,但在另一页上无效 [英] Session works in one page but not another

查看:104
本文介绍了会话在一页上有效,但在另一页上无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用php图表包.我从发送到answer.php页面的form.html开始. answer.php创建会话.然后,所需的test.php页开始了会话,但所需的graph.php页却没有.我无法将数据从表单传输到图形.所需的phplot.php是图形引擎,并且在SESSION线程中不需要.

I am working in a php charting package. I start with a form.html that sends to an answer.php page. The answer.php creates the SESSION. Then a required test.php page picks up the session but the required graph.php page does not. I cannot transfer my data from the form to the graph. The required phplot.php is the graph engine and is not needed in the SESSION thread.

我花了五天的时间进行研究和测试,但没有运气.我已经多次切换了编码.我希望具有丰富php经验的人能够轻松识别某些东西.

I have spent five days researching and testing with no luck. I have switched the coding around many times. I'm hoping that someone with great php experience will recognize something easily.

下面是这三页的编码.

answer.php页面:

answer.php page:

<?php
session_unset();
session_start();
require_once 'phplot/test.php';
?>
<?php
$_POST['bs_now2'];$bs_now2 = $_POST['bs_now2'];$_SESSION['bs_now2'] = $bs_now2;
echo "<div id='graph'>";
echo "<p class='martop10 f18 b'>Graph:</p>";
echo "<img src='phplot/graph.php'>";
echo "</div>";
?>
<?php
session_destroy();
?>

graph.php页面:

graph.php page:

<?php
$Sbs_now2 == 0;
session_start();# Is this redundant? I've tried it in and out.
?>
<?php
require_once 'phplot.php';#Graph engine
$delta = 0.1;$sigma = 15;$sqrt2pi = sqrt(2*M_PI);$u = 75;
$data = array();
for ($x = 0; $x <= 150; $x++)
  $data[] = array('', $x, $Sbs_now2 + $x);
unset($Sbs_now2);
?>

test.php页面:

test.php page:

<?php
#I don't need the session_start() for this page
$_POST['bs_now2'];$bs_now2 = $_POST['bs_now2'];$_SESSION['bs_now2'] = $bs_now2;$Sbs_now2 = $_SESSION['bs_now2'];
echo '<b>Session BS Now: '.$Sbs_now2.'</b><br>';
?>

谢谢

加里

推荐答案

Luiz Fernando Sousa Camargo和所有,

Hi Luiz Fernando Sousa Camargo and All,

在Luiz Fernando Sousa Camargo的帮助下,我知道了!

With help from Luiz Fernando Sousa Camargo I have got it!

answer.php页面有一项更改:

answer.php page has one change:

<?php
session_unset();
session_start();
require_once 'phplot/test1.php';
?>
<?php
$_POST['bs_now2'];$bs_now2 = $_POST['bs_now2'];$_SESSION['bs_now2'] = $bs_now2;$Sbs_now2 = $_SESSION['bs_now2'];
echo "<div id='graph'>";
echo "<p class='martop10 f18 b'>Graph:</p>";
echo "<img src='phplot/bs4c.php?bs_now2=$Sbs_now2'>";#CHANGE:
#I set bs_now2= to the session variable(as it would come from the form input). No other changes.
echo "</div>";
?>
<?php
session_destroy();
?>

graph.php页面有一项重要更改:

graph.php page has a one important change:

<?php
$Sbs_now2 == 0;
session_start();
$_GET['bs_now2'];$bs_now2 = $_GET['bs_now2'];$_SESSION['bs_now2'] = $bs_now2;$Sbs_now2 = $_SESSION['bs_now2'];#CHANGE
#Use GET to acquire the session variable
#Remove End php and Start php Marks(not important)
require_once 'phplot.php';
$data = array();
for ($x = 0; $x <= 150; $x++)
  $data[] = array('', $x, $Sbs_now2 + $x);
unset($Sbs_now2);
?>

谢谢Luiz Fernando Sousa Camargo和所有人,

Thank you Luiz Fernando Sousa Camargo and All,

加里

这篇关于会话在一页上有效,但在另一页上无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆