我的观点是在发送表单显示会话数据之后。
form.html:
<form action="sendForm.php" name="f" method="post" onsubmit="return sendForm()" >
<div class="form">
<label for="imie">Name</label>
<input type="text" id="nam" name="nam"/><br/>
<label for="nazwisko">Surname</label>
<input type="text" id="surname" name="surname"/><br/>
</div>
<input type="submit" name="send" id="send" value="send form"/><br/><br/>
</form>
sendForm.php:
<?php
session_start();
$_SESSION['nam'] = $_POST['nam'];
$_SESSION['surname'] = $_POST['surname'];
header("Location: view-struct.php");
?>
视图-struct.php:
<span class="label">Name</span><?php echo $_SESSION['nam']; ?><br/>
<span class="label">Surname</span><?php echo $_SESSION['surname']; ?><br/>
[编辑]问题已关闭,忘记为view-struct.php中的session_start()添加