Pass checkbox results through step by step form
<p>I have a step by step form that I want to pass checkbox results through to a review page at the end.</p>

<p>There's checkboxes in step 1 and 2, how can I show these on step 3?</p>

<p>I've attempted to do it below but can't get it to echo out the results.</p>

<pre><code>&lt;form class="form" method="POST" action="&lt;?php the_permalink(); ?&gt;"&gt;
&lt;? if (!$_POST['step']) { ?&gt;
&lt;input type="hidden" name="step" value="1" /&gt;
&lt;div class="steps" style="float:left;"&gt;
  &lt;p style="font-size:17px!IMPORTANT;"&gt;&lt;b&gt;Step 1 of 3&lt;/b&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div class="progress-buttons" style="float:right;"&gt;
  &lt;button class="next" type="submit" name="submit"&gt;Next&lt;/button&gt;
&lt;/div&gt;
&lt;div class="clear"&gt;&lt;/div&gt;
&lt;?php $posts = get_field('options');
                            if( $posts ):
                            $items = 0;
                            foreach( $posts as $post): // variable must be called $post (IMPORTANT)
                                setup_postdata($post); ?&gt;
&lt;p style="clear:right;float:right;margin-right:60px;"&gt;
  &lt;input type="checkbox" name="hardware[]" value="&lt;?php the_title(); ?&gt;"&gt;
  Select&lt;/p&gt;
&lt;?php $items++; endforeach;
                            wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly
                            endif; ?&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;? } else if ($_POST['step'] == 1) {
foreach($_POST as $name =&gt; $value) {
    if ($name == "hardware") {
        $_SESSION[$name] = $_POST[$name];
    } else if ($name &lt;&gt; "step") { echo "&lt;input type=\"hidden\" name=\"$name\" value=\"$value\" /&gt;"; }
} ?&gt;
&lt;input type="hidden" name="step" value="2" /&gt;
&lt;div class="steps" style="float:left;"&gt;
  &lt;p style="font-size:17px!IMPORTANT;"&gt;&lt;b&gt;Step 2 of 3&lt;/b&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div class="progress-buttons" style="float:right;"&gt; &lt;a class="back" href="&lt;?php the_permalink(); ?&gt;?&lt;?= $field ?&gt;" &gt;Back&lt;/a&gt;
  &lt;button class="next" type="submit" name="submit"&gt;Next&lt;/button&gt;
&lt;/div&gt;
&lt;?php $posts = get_field('accessories');
                            if( $posts ):
                            $items = 0;
                            foreach( $posts as $post): // variable must be called $post (IMPORTANT)
                                setup_postdata($post); ?&gt;
&lt;p style="clear:right;float:right;margin-right:60px;"&gt;
  &lt;input type="checkbox" name="accessories[]" value="&lt;?php the_title(); ?&gt;"&gt;
  Select&lt;/p&gt;
&lt;?php $items++; endforeach;
                            wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly
                            endif; ?&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;? } else if ($_POST['step'] == 2) {
foreach($_POST as $name =&gt; $value) {
    if ($name == "accessories") {
        $_SESSION[$name] = $_POST[$name];
    } else if ($name &lt;&gt; "step") { echo "&lt;input type=\"hidden\" name=\"$name\" value=\"$value\" /&gt;"; }
} ?&gt;
&lt;input type="hidden" name="step" value="3" /&gt;
&lt;div class="steps" style="float:left;"&gt;
  &lt;p style="font-size:17px!IMPORTANT;"&gt;&lt;b&gt;Step 3 of 3&lt;/b&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div class="progress-buttons" style="float:right;"&gt; &lt;a class="back" href="&lt;?php the_permalink(); ?&gt;?&lt;?= $field ?&gt;" &gt;Back&lt;/a&gt;
  &lt;button class="next" type="submit" name="submit"&gt;Next&lt;/button&gt;
&lt;/div&gt;
&lt;div class="clear"&gt;&lt;/div&gt;
&lt;p&gt;System spec&lt;/p&gt;
&lt;?php
$hardware = $_POST['hardware'];
$accessories = $_POST['accessories'];
if( is_array($_SESSION['hardware']) ){
    foreach ($_SESSION['hardware'] as $val) {
        $hardwareresults .= $val.",\n";
    }
}
if( is_array($_SESSION['accessories']) ){
    foreach ($_SESSION['accessories'] as $val) {
        $accessoriesresults .= $val.",\n";
    }
}
?&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;?php echo $hardwareresults; ?&gt;&lt;/li&gt;
  &lt;li&gt;&lt;?php echo $accessoriesresults; ?&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;? } else if ($_POST['step'] == 3) { //do stuff ?&gt;
Last step
&lt;?php } ?&gt;
</code></pre>
