我正在创建一个页面,它会让用户通过几种形式。我设置SESSION变量来存储数据,但是它们没有保存。有什么我想念的吗?
在页面顶部,我在HTML标记之前声明了session_start()
。
它声明了这个特定的实例,但随后该值丢失了
?>
<form role="form" class="title" method="POST" action="?action=materials">
<label for="title">Project Title</label>
<input type="text" name="title" value="">
<label for="description">Description</label>
<textarea name="description"></textarea>
<input type="submit" name="submit" value="next>">
</form>
<?php
$title = Input::get("title"); //Input::get() gets form values
$description = Input::get('description');
$_SESSION["title"] = $title; // set SESSION variable
$_SESSION["description"] = $description;
echo $_SESSION["title"], $_SESSION["description"]; // prints variable... works beautifully
?>
<form class="my-form" role="form" method="POST" action="?action=steps">
<p class="text-box">
<label for="materials">Materials</label>
<p class="text-box">
<label for="url">URL</label>
<a class="add-box" href="#">Add Material</a>
</p>
<input type="submit" name="submit" id="btnsbmit" value="next>">
</form>
<?php
$elems = Input::get("elem1");
echo $_SESSION["title"], $_SESSION["description"]; // print same session variable... does not print
?>
<!--more code-->