title: PHP Caesar cipher
body: <p>(jsfiddle example here: <a href="http://jsfiddle.net/HP3y7/3/" rel="nofollow">caesar cipher</a>)</p>
  
  <p>I am making a Caesar cipher - it's an alphabetic shift, basically; a shift parameter of 3 is as follows:
  a => d, b => e, c => f, ...</p>
  
  <p>My code so far is</p>
  
  <pre><code>$string = "hello";
  echo "&lt;p&gt;" . $string . "&lt;/p&gt;";
  $newstring = "hello";
  
  for ($i=0;$i&lt;strlen($string);$i++) {
  
      $ascii = ord($string[$i]);
      if($ascii == 90) { //uppercase bound
          $ascii = 65; //reset back to 'A' 
          } 
      else if($ascii == 122) { //lowercase bound
          $ascii = 97; //reset back to 'a' 
          } 
      else {
          $ascii++;
      }
      $newstring[$i] = chr($ascii);
  
  }
  
  echo "&lt;p&gt;" . $newstring . "&lt;/p&gt;";
  </code></pre>
  
  <p>and it works okay.</p>
  
  <p>I would like a user to be able to enter their own string into a form's textarea as follows:</p>
  
  <pre><code>&lt;form&gt;
      &lt;table&gt;
          &lt;tr&gt;&lt;th class="w"&gt;Message:&lt;/th&gt;
              &lt;td&gt;&lt;textarea class="t" onfocus='this.select()' name=msg&gt;HELLO&lt;/textarea&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;&lt;th&gt;Shift Parameter:&lt;/th&gt;
              &lt;td&gt;&lt;input type=text size=2 name=sp value='11'&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;input type=submit name=submit value='Encode'&gt;
          &lt;input type=submit name=submit value='Decode'&gt;
          &lt;input type=button value='Clear' onclick='this.form.elements.msg.value=""'&lt;/td&gt;&lt;/tr&gt;
      &lt;/table&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>I just need to change the PHP to output the table, but don't quite know how. So, in textarea, a user could type "TESTING", choose a shift parameter of 8, and click "Encode" and that would run an encode function; likewise, "Decode" would run a decode function.</p>
  
  <p>Any ideas how to change the PHP code to make it work the way I'd like?</p>