forum

Home / DeveloperSection / Forums / Working with sessions and POST

Working with sessions and POST

Anonymous User279401-Nov-2014

I am starting to make a step system, vote for this page, and then next step.

I tested how sessions work now, and trying to make it so whenever you click continue, it will add + 1 to session number:

$_SESSION['vote_id']=1;if(isset($_POST['continue'])){if($_SESSION['vote_id']==1){ $_SESSION['vote_id']=2;}elseif($_SESSION['vote_id']==2){ $_SESSION['vote_id']=3;}}

But now, when I click continue, it goes to 2, that's nice, but when I click continue again, it stays at 2?

What's wrong?

<?php
            if (isset($_SESSION['vote_id']))
            {
                if ($_SESSION['vote_id'] == 1)
                {
                    echo '1';
                }
                else if ($_SESSION['vote_id'] == 2)
                {
                    echo '2';
                }
                else if ($_SESSION['vote_id'] == 3)
                {
                    echo '3';
                }                   
            }
        ?>
        <span id="head">Welcome</span><br /><br />
        <span id="paragraph">
        We currently have 7 voting sites. 
        Don't be afraid! We do NOT require you to vote on them all.
        You will receive one point per vote, to finish voting, please click on the
        button "Finish Voting" ad you will receive your points
        </span><br /><br />
        <form action="index.php" method="post">
        <span id="head">Voting site 1: Runelocus</span><br /><br />
        <div class="button" name="runelocus">Runelocus Vote</div><br /><br />
        <input type="submit" class="button_green" id="right" name="continue" value="Continue">
        </form>
        <?php
            echo $_SESSION['vote_id']; 
        ?>

Updated on 01-Nov-2014
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By