0

I have the following code in index.php:

<div class="done">
        <b>Thank you<?php
             echo $_SESSION['session_vname']." "; 
             echo $_SESSION['session_lname']."! </b><br><br>Email: ";
             echo $_SESSION['session_email']."<br> Status: ";
             echo $_SESSION['session_status']."<br>";

        ?>
    </div>

and

<div class="form">
        <form method="post" action="process.php">
            <div class="element">
                <label>First Name</label>
                <input type="text" name="vname" class="text" />
            </div>
            <div class="element">
                <label>Last Name</label>
                <input type="text" name="lname" class="text" />
            </div>
            <div class="element">
                <label>Email</label>
                <input type="text" name="email" class="text" />
            </div>
            <div class="element">
                <label>Status</label>
                <input type="text" name="status" class="text" />
            </div>
            <div class="element">
                <input type="submit" id="submit"/>
                <div class="loading"></div>
            </div>
        </form>
    </div>

I execute the form with an ajax submit so the index.php gets no refresh. When finished gets a fadeOut and a fadeIn.

This works fine except for the following part:

When div class="form" is shown, it shows the session variable from the form before the last submit.

Example:

first input: session_vname = testa

first output $_SESSION['session_vname'] = nothing

second input: session_vname = overflow

second output $_SESSION['session_vname'] = testa

So finally the question:

How can I force the to update the session variables after form submitting also index.php is not reloaded?

2 Answers 2

1

PHP code is executed on server side, before the page is shown to the viewer. That means you need to update static elements with JavaScript if you don't want to refresh the whole page.

Sign up to request clarification or add additional context in comments.

Comments

0

You cant update server side php sessions using javascript, you should be using cookies for that type of functionality

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.