我有一份很长的数据信息表,我将其分为三页 我一直想做的是:
- 在第1页开始会话以将数组$ sda转移到第2页,
- 在第2页上有一个会话来将数组$ sda和$ sdb数据转移到第3页,
- 并在第3页上,将所有数组数据插入数据库并结束会话。
醇>
但是,在第3页上,第1页的数组$ sda变为null,只传输数组$ sdb。我没有做什么?
这是我的代码:
第1页,用户填写表单,将值放入数组$ sda,用户点击提交
session_start();
$_SESSION['sda'] = $sda;
header("location:enrol.php?a=2");
第2页
session_start();
$sda = $_SESSION['sda'];
print_r($_SESSION);
用户填写表单,将值放入数组$ sdb,(数组$ sda中的值应该保留并传递到第3页。它不需要在此页面中打印,但我这样做是为了检查我是否可以从上一页访问其内容 - 工作正常并打印
Array ( [sda] => Array ( [0] => First [1] => Mid [2] => Last [3] => Nick [4] => Cit [5] => Place [6] => January [7] => 1 [8] => 2012 [10] => Grade 1 [9] => School [11] => Home [12] => [13] => A@B.C [14] => [15] => [16] => Guard [17] => Rel [18] => 12345678 [19] => [20] => [21] => [22] => [23] => [24] => [25] => [26] => [27] => [28] => [29] => [30] => [31] => [32] => [33] => [34] => [35] => [37] => [39] => [41] => [36] => [38] => [40] => ) [sdb] => Array ( [9] => [10] => [11] => [12] => [13] => [14] => [15] => [16] => [17] => [18] => [19] => [20] => [21] => a [22] => b [23] => c [24] => d [25] => e [26] => f ) )
用户点击提交(我只想在下一页上看$ sda值。我做得对吗?:z)
session_start();
$_SESSION['sda'] = $sda;
$_SESSION['sdb'] = $sdb;
header("location:enrol.php?a=3");
第3页
session_start();
$sda = $_SESSION['sda'];
$sdb = $_SESSION['sdb'];
print_r($_SESSION);
错误在这里!虽然打印了$ sdb值,但SDA值仍然很低;
Array ( [sda] => [sdb] => Array ( [9] => [10] => [11] => [12] => [13] => [14] => [15] => [16] => [17] => [18] => [19] => [20] => [21] => a [22] => b [23] => c [24] => d [25] => e [26] => f ) )
提交
保存到数据库并销毁会话
答案 0 :(得分:0)
从
之后返回的代码中删除此行 user clicks submit (I just want $sda values on the next page. Am I doing it right? :z)
即
$_SESSION['sda'] = $sda;