title: PHP - Passing Session Data To Another Page Using Radio Buttons
body: <p>I know this question has come up several times. </p>
  
  <p>I read all of the posts and tried them but couldn't get them to work. </p>
  
  <p>I simply want to pass the session data from <code>page 1</code> to <code>page 2</code> for a radio button. It won't work no matter what I've tried.</p>
  
  <p><strong>Page 1</strong></p>
  
  <pre><code>&lt;form action="step-2.php" method="post"&gt;
      &lt;div class="row"&gt;
          &lt;div class="card-left"&gt;&lt;img src="card.png" /&gt;&lt;br /&gt;&lt;input type="radio" name="card" value="card-one" /&gt;&lt;/div&gt;
          &lt;div class="card-center"&gt;&lt;img src="card.png" /&gt;&lt;input type="radio" name="card" value="card-two" /&gt;&lt;/div&gt;
          &lt;div class="card-right"&gt;&lt;img src="card.png" /&gt;&lt;input type="radio" name="card" value="card-three" /&gt;&lt;/div&gt;
          &lt;div class="card-right"&gt;&lt;img src="card.png" /&gt;&lt;input type="radio" name="card" value="card-four" /&gt;&lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="row"&gt;
          &lt;div class="card-left"&gt;&lt;img src="card.png" /&gt;&lt;br /&gt;&lt;input type="radio" name="card" value="card-five" /&gt;&lt;/div&gt;
          &lt;div class="card-center"&gt;&lt;img src="card.png" /&gt;&lt;input type="radio" name="card" value="card-six" /&gt;&lt;/div&gt;
          &lt;div class="card-right"&gt;&lt;img src="card.png" /&gt;&lt;input type="radio" name="card" value="card-seven" /&gt;&lt;/div&gt;
          &lt;div class="card-right"&gt;&lt;img src="card.png" /&gt;&lt;input type="radio" name="card" value="card-eight" /&gt;&lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="row"&gt;
          &lt;div class="card-left"&gt;&lt;img src="card.png" /&gt;&lt;br /&gt;&lt;input type="radio" name="card" value="card-nine" /&gt;&lt;/div&gt;
          &lt;div class="card-center"&gt;&lt;img src="card.png" /&gt;&lt;input type="radio" name="card" value="card-ten" /&gt;&lt;/div&gt;
          &lt;div class="card-right"&gt;&lt;img src="card.png" /&gt;&lt;input type="radio" name="card" value="card-eleven" /&gt;&lt;/div&gt;
          &lt;div class="card-right"&gt;&lt;img src="card.png" /&gt;&lt;input type="radio" name="card" value="card-twelve" /&gt;&lt;/div&gt;
      &lt;/div&gt;
      &lt;div id="messages"&gt;
  
      &lt;?php
  
      if($_SERVER['REQUEST_METHOD'] == 'POST') {
          if(isset($_POST["card"])) {
              session_start();
              $_SESSION["card"] == $_POST["card"];
          }
  
  
          if(!isset($_POST["card"])) {
              echo '&lt;span style=\"color: red;\"&gt;' . "Please choose a card before proceeding" . '&lt;/p&gt;';
          } else {
  
          }
  
      } else { }
  
      ?&gt;
      &lt;input type="submit" name="to-step-2" value="Next" id="submit" /&gt;&lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>Page 2 (won't receive and display the data)</strong></p>
  
  <pre><code>&lt;?php
  
  if(isset($_SESSION["card"])) {
      $card = $_SESSION["card"];
      echo $card;
  } else {
      echo "&lt;h2&gt;No Card Selected&lt;/h2&gt;";
      echo "You didn't select a card. Please go back and select one &lt;a href=\"index.php \"&gt;Here&lt;/a&gt;";
  }
  
  ?&gt;
  </code></pre>
  
  <p>I'm just trying to test this in this state so that I can make sure that the data is being passed and then I will work with the data, but right now it doesn't look like the data is being passed. It instead triggers the default "You didn't select a card" message that I have set up.</p>