title: Linking my encryption class to the DB and HTML form
body: <p>I'm going to jump in straight away.. I currently have the following code:</p>
  
  <p>An Encryption Class:</p>
  
  <pre><code>class Encryption {
      var $skey = "cryptkey";
  
      public  function safe_b64encode($string) {
          $data = base64_encode($string);
          $data = str_replace(array('+','/','='),array('-','_',''),$data);
          return $data;
      }
  
      public function safe_b64decode($string) {
          $data = str_replace(array('-','_'),array('+','/'),$string);
          $mod4 = strlen($data) % 4;
          if ($mod4) {
              $data .= substr('====', $mod4);
          }
          return base64_decode($data);
      }
  
      public  function encode($value){ 
          if(!$value){return false;}
          $text = $value;
          $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
          $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
          $crypttext = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $this-&gt;skey, $text, MCRYPT_MODE_ECB, $iv);
          return trim($this-&gt;safe_b64encode($crypttext)); 
      }
  
      public function decode($value){
          if(!$value){return false;}
          $crypttext = $this-&gt;safe_b64decode($value); 
          $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
          $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
          $decrypttext = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $this-&gt;skey, $crypttext, MCRYPT_MODE_ECB, $iv);
          return trim($decrypttext);
      }
  }
  </code></pre>
  
  <p>And this is the code used to utilise the class:</p>
  
  <pre><code>    $str = "password";
  
  $converter = new Encryption;
  $encoded = $converter-&gt;encode($str );
  $decoded = $converter-&gt;decode($encoded);    
  
  echo "$encoded&lt;p&gt;$decoded";
  </code></pre>
  
  <p>This is the HTML Form I'd like to run the encryption class on:</p>
  
  <pre><code>&lt;form action="#" method="post"&gt;                                    
                    &lt;div class="login-fields"&gt;
  
                      &lt;div class="field"&gt;
                        &lt;label for="website_name"&gt;Website Name&lt;/label&gt;
                        &lt;input type="text" id="webname" name="webname" value="" placeholder="Website Name" class="login website-field"/&gt;
                      &lt;/div&gt; &lt;!-- /website name --&gt;
  
                      &lt;div class="field"&gt;
                        &lt;label for="username"&gt;Username&lt;/label&gt;
                        &lt;input type="text" id="username" name="username" value="" placeholder="Username" class="login username-field" /&gt;
                      &lt;/div&gt; &lt;!-- /field --&gt;
  
                      &lt;div class="field"&gt;
                        &lt;label for="password"&gt;Password:&lt;/label&gt;
                        &lt;input type="password" id="password" name="password" value="" placeholder="Password" class="login password-field"/&gt;
                      &lt;/div&gt; &lt;!-- /password --&gt;
  
                      &lt;div class="field"&gt;
                        &lt;label for="cryptkey"&gt;Encryption Key:&lt;/label&gt;
                        &lt;input type="text" id="cryptkey" name="cryptkey" value="" placeholder="Encryption Key" class="login crypt-field"/&gt;
                      &lt;/div&gt; &lt;!-- /password --&gt;
  
                    &lt;/div&gt; &lt;!-- /login-fields --&gt;
  
                    &lt;div id="saveBtn"&gt;                 
                      &lt;button class="button btn btn-index btn-large"&gt;Save&lt;/button&gt;
                    &lt;/div&gt; &lt;!-- .actions --&gt;
  
  
  
                  &lt;/form&gt;
  </code></pre>
  
  <p>And so this is basically what I'm trying to do. The form will accept input from the user to save the following information. The password is the only thing that needs to be encrypted; and the stored entries need to be saved on a separate table for each user.</p>
  
  <p>How do I implement what I just stated above? Whereby whatever is inserted into the password field is encrypted and saved onto a database that is specific to a user's account? If anything needs clarifying please do ask and I'll try my best!</p>
  
  <p>Thank you very much in advance.</p>