title: PHP: how to create a Story progressing "Case" ? and Debugging
body: <p>This is rather simple: I still have some problems to create good, conclusive questions but i try my best.</p>
  
  <p>I want to create a php Code that <strong>progresses</strong> while the user is submitting the information with some radio buttons. There is a script example i wrote so far.</p>
  
  <p>Every Time the user clicks a radio button and submits the content the code should progress and $count gets a + 1. So far i created two steps of progression.  Everytime the user chose one radio button and clicks the submit button the program should echo something else insteat what it does right now is it echos everything of the chosen radiobutton in one step. (what i don't want to have)</p>
  
  <p>I don't know why that is so. Shouldn't <strong>break</strong> in <strong>Case</strong> stop the code and restart it? </p>
  
  <p>I used CASE for this and i am pretty sure that is not the best way, if it is a way at all because it does not work. I think every time the user clicks the submit button the whole code resets instead of that the progression is saved. </p>
  
  <p>What do i have to do? Do i have to use <strong>arrays</strong> to save the clicked information or do i have to use <strong>LOOPS?</strong> I tried around with both but i still have no solution for my problem. </p>
  
  <p>What would be the simplest solution for the code i have in mind? One step further i want to create a simple text adventure with php. I have to learn PHP for a Test and i think to play around with the code a little will help me to understand how it works. </p>
  
  <p>Here is the code i wrote but i think i have to rearrange it and to use other things istead of case to make it work. </p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
    &lt;title&gt;Abfrage&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
   &lt;h4&gt; Typentest&lt;/h4&gt;
   &lt;form action="&lt;?php echo $_SERVER['PHP_SELF'] ?&gt;"method="post"&gt;
   &lt;p&gt;What would you chose?&lt;/p&gt;&lt;br /&gt;
  
          &lt;input type="radio" id="a1" name="weapon" value="1" checked&gt; &lt;label for="a1"&gt; Dagger&lt;/label&gt;&lt;br&gt;
          &lt;input type="radio" id="a2" name="weapon" value="2"&gt; &lt;label for="a2"&gt; Sword&lt;/label&gt;&lt;br&gt;
          &lt;input type="radio" id="a3" name="weapon" value="3"&gt; &lt;label for="a3"&gt; Saber&lt;/label&gt;&lt;br&gt;
  
  
  
          &lt;input type="submit" name="gesendet" value="ok"&gt;&lt;/button&gt; &lt;br /&gt;
      &lt;/form&gt;
  
  
      &lt;?php
  
          if(isset($_POST['gesendet'])){
          // Variablen deklararien und Werte zuweisen.
              $weapon = $_POST['weapon'];
              $count = 0;
  
  
          //First chosing
  
              if (!empty($weapon) &amp;&amp; $count == 0){
  
                  switch($weapon){
                      case "1":
                         echo "You chose a crude dagger ";
                         $count = $count + 1;
                         break;
                      case "2":
                         echo "You chose a crude sword";
                         $count = $count + 1;
                         break;
                      case "3":
                         echo "you chose a crude saber";
                         $count = $count + 1;
                         break;
  
  
                  }
  
              }
              //second chosing after second time "submit"
              if (!empty($alter) &amp;&amp; $count == 1){
  
                  switch($alter){
                      case "1":
                         echo "you chose a fine dagger";
                         $count = $count + 1;
                         break;
                      case "2":
                         echo "you chose a fine sword";
                         $count = $count + 1;
                         break;
                      case "3":
                         echo "you chose a fine saber";
                         $count = $count + 1;
                         break;
  
  
                  }
  
              }
  
  
              else {
  
                  echo "Ihre Eingabe ist fehlerhaft ";
              }   
          }
  
  
      ?&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p></p>