title: Dynamic Text Using JavaScript & PHP?
body: <p>I'm working on a little project, basically I have some text on my PHP/HTML page that is being echo'ed from a variable ($brief_string). </p>
  
  <p>There is also a back, and continue button which basically subtracts or adds to another variable ($brief_page - which is pulled from my DB). The brief_string changes depending on the brief_page by using if statements. First problem I encounter is that when I hit continue (submit button) it resubmits/refreshes the page, causing my brief_page to reset back to 0.</p>
  
  <p>So I'm thinking maybe I could use JS to hold the info and page variables and control the dynamic text, but then, how would I update my DB with the current page value via JS? Isn't it really easy to manually change/hack these values? I would preferably like my DB to be updated with the page number each time the use presses the back/continue button.</p>
  
  <p>I would just like some advice really as I am a student trying to develop an interactive book like site (that uses a DB to save your current page).</p>
  
  <p>Code:</p>
  
  <pre><code>&lt;?
  $brief_info = "brief info goes here";
  $brief_page = 0; //&lt; will soon be pulled off DB
  
  if (isset($_GET['brief1Go'])) {
      $brief_page = $brief_page + 1;
  }
  else if (isset($_GET['brief1Back'])) {
      $brief_page = $brief_page - 1;
  }
  
  
  $breifController = "
      &lt;form action=\"".$_SERVER['PHP_SELF']."\" method=\"POST\"&gt;
          &lt;input type=\"submit\" name=\"brief1Back\" id=\"brief1Back\" value=\"BACK\" /&gt;
      &lt;/form&gt;
  
      &lt;form action=\"".$_SERVER['PHP_SELF']."\" method=\"POST\"&gt;
          &lt;input type=\"submit\" name=\"brief1Go\" id=\"brief1Go\" value=\"CONTINUE\" /&gt;
      &lt;/form&gt;";
  
  
  
  if($brief_page == 0){
      $brief1_info = "&lt;b&gt;Welcome Commander,&lt;/b&gt; you are currently viewing the Mission Control Brief page, here you can view all your missions that you need to complete in order to advance through your prestiges. You will need to follow your briefs carefully in order to succeed. &lt;br /&gt;&lt;br /&gt;
  
      ";
  }
  else if($brief_page == 1){
      $brief_info = "Okay, let me show you around the place ...";
  }
  else if($brief_page == 2){
      $brief_info = "brief is on 2";
  }
  
  ?&gt;
  </code></pre>