我想根据提交的表单更改会话变量。
ob_start();
session_id("oneway");
session_start();
if (isset($_POST['oneway_book'])) {
$_SESSION["source_oneway"] = $_POST['oneway_source'];
$_SESSION["dest1"] = $_POST['oneway_destinations'];
$_SESSION["date1"] = $_POST['oneway_date'];
$_SESSION["time1"] = $_POST['oneway_time'];
header('Location: new.php?oneway');
# code...
}
elseif (isset($_POST['twoway_submit'])) {
$_SESSION["source_oneway"] = $_POST['twoway_source'];
$_SESSION["dest1"] = $_POST['twoway_destinations'];
$_SESSION["date1"] = $_POST['twoway_date1'];
$_SESSION["time1"] = $_POST['twoway_time1'];
$_SESSION["date21"] = $_POST['twoway_date2'];
$_SESSION["time21"] = $_POST['twoway_time2'];
header('Location: new.php?roundtrip');
# code...
}
问题是我正在为"单向"显示正确的会话变量。但我得到了elseif条件的空变量。
答案 0 :(得分:0)
也许永远不会设置$_POST['twoway_submit']
,因此你的elseif没有被执行?
您是否尝试使用xdebug进行调试?
或者$_POST['oneway_book']
总是被设置,所以elseif块永远不会被执行?