title: After changing my .htaccess file, my POST method on my php no longer works
body: <p>I recently did some research to find out how to modify my .htaccess file to hide the .php extension in the URL. I got it to work how I wanted with the following code:</p>
  
  <pre><code>RewriteEngine On
  
  # Unless directory, remove trailing slash
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^([^/]+)/$ http://www.guitrum.com/$1 [R=301,L]
  
  # Redirect external .php requests to extensionless url
  RewriteCond %{THE_REQUEST} ^(.+)\.php([#?][^\ ]*)?\ HTTP/
  RewriteRule ^(.+)\.php$ http://www.guitrum.com/$1 [R=301,L]
  
  # Resolve .php file for extensionless php urls
  RewriteRule ^([^/.]+)$ $1.php [L]
  
  ErrorDocument 404 /404.php
  
  DirectoryIndex index.php
  </code></pre>
  
  <p>Unfortunately, part of my php script is broken now. Keep in mind, before modifying my .htaccess file, everything worked. On a log in page, I have some script to pass some user input with the POST method like so:</p>
  
  <pre><code>&lt;form method='POST' action='loginconfirm.php'&gt;
  Password: &lt;input type='password' name='password'&gt;&lt;/input&gt;
  &lt;input type='submit' name='submit' value='Go'&gt;&lt;/input&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>on the loginconfirm.php page, I have an encryption class as an included file in the page with the following code:</p>
  
  <pre><code>&lt;?php
  //source: http://stackoverflow.com/questions/2448256/php-mcrypt-encrypting-decrypting-file
  class Encryption {
  
      const CYPHER = MCRYPT_RIJNDAEL_256;
      const MODE = MCRYPT_MODE_CBC;
      const KEY = 'SecretKey';
  
      public function encrypt($plaintext) {
          $td = mcrypt_module_open(self::CYPHER, '', self::MODE, '');
          $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
          mcrypt_generic_init($td, self::KEY, $iv);
          $crypttext = mcrypt_generic($td, $plaintext);
          mcrypt_generic_deinit($td);
          return rawurlencode(base64_encode($iv . $crypttext));
      }
  
      public function decrypt($crypttext) {
          $crypttext = rawurldecode($crypttext);
          $crypttext = base64_decode($crypttext);
          $plaintext = '';
          $td = mcrypt_module_open(self::CYPHER, '', self::MODE, '');
          $ivsize = mcrypt_enc_get_iv_size($td);
          $iv = substr($crypttext, 0, $ivsize);
          $crypttext = substr($crypttext, $ivsize);
          if ($iv) {
              mcrypt_generic_init($td, self::KEY, $iv);
              $plaintext = mdecrypt_generic($td, $crypttext);
          }
          return trim($plaintext);
      }
  
  }
  
  //source: http://stackoverflow.com/questions/2448256/php-mcrypt-encrypting-decrypting-file
  ?&gt;
  </code></pre>
  
  <p>The first thing I do on the page is set a new variable that has the password encrypted like so:</p>
  
  <pre><code>&lt;?php
  include ("includefiles/EncryptionUtilities.php");
  $passworde = Encryption::encrypt($_POST['password']);
  setcookie('password', $passworde, time() + (60 * 5));
  ?&gt;
  </code></pre>
  
  <p>When normally it would work fine, now it throws errors saying that:</p>
  
  <blockquote>
    <p>an empty string was passed into EncryptionUtilities.php, and cannot modify header information - headers already sent.</p>
  </blockquote>
  
  <p>I think there is something wrong with the .htaccess file that is not allowing the POST method to talk between pages.</p>