我有问题,无法理解为什么这不起作用。语言未转移,我看到空白区域。
在我的PHP中:
<?php
$_SESSION['Language'] = $_GET['Spanish'];
header("Location:../index.php");
exit;
?>
在index.php中:
<?php
$Language = $_SESSION['Language'];
include 'header.php';
echo '<div id="content">
<img src="Images/SplashScreen.jpg" id="bgImage" alt="City" width="1280" height="720" />
<div class="splashOuterRingsOverlay" id="contain">
<img src="Images/Loading-outer-circle.png" id="image1" alt="inner ring" width="282" height="282">
</div>
<div class="splashInnerRingsOverlay" id="contain">
<img src="Images/Loading-inner-circle.png" id="image2" alt="outer ring" width="282" height="282">
</div>
<div class="splashButtonOverlay">
<!--<button type="button" id="splashButton" onclick="loadData(20)"></button>-->
<button type="button" id="splashButton" onclick="loadLangCustom(\'Spanish\')"></button>
</div>
<div class="splashTitleOverlay">
<p id="splashTitle">'.$Language.'</p>
<!--<p id="splashTitle">Please press BERMAD icon</p>-->
</div>
</div>';
include 'footer.php';
?>
答案 0 :(得分:3)
如果设置会话变量,则必须在php页面的顶部添加session_start。
session_start()根据通过GET或POST请求传递的会话标识符创建会话或恢复当前会话,或通过cookie传递。
像这样更改你的代码
<?php
session_start();
if (isset( $_GET['Spanish'])) {
$_SESSION['Language'] = $_GET['Spanish'];
header("Location:../index.php");
exit;
}
?>
答案 1 :(得分:2)
在代码的开头添加session_start()
-
<?php
session_start();
$_SESSION['Language'] = $_GET['Spanish'];
<?php
session_start();
$Language = $_SESSION['Language'];
答案 2 :(得分:2)
session_start()
和index.php
my.php