0

I am creating a page, which takes the user through a few forms. I set the SESSION variables to store the data, however they are not saving. Is there something I'm missing?

At the top of the page I have session_start()declared before the HTML tags.

This particular instance it's declared, but then the value is lost

?>
                <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-->
  • print_r($_SESSION) after session_start() and post your form and check what you get. – Suman Singh Dec 23 '16 at 02:35
  • I've been having the same issue, as a temporary workaround, I used cookies, though definitely not the same, they are somewhat similar, and it still allowed me to get the job done in time. – harryparkdotio Dec 23 '16 at 02:36
  • its hard to understand your problem. Can you perhaps remove the unnecessary code and show your `session_start` on the code? – CodeGodie Dec 23 '16 at 02:38

0 Answers0