title: login system via on localhost not working
body: <p>I had built a login system (with registration function) and tested it on my server (separate computer on same network) and it all worked fine.</p>
  <p>Then I copied the code to my main computer to use it on localhost. Apache server and MySQL server was done throught XAMPP.</p>
  <p>When entering the credentials and clicking submit, chrome answers with a HTTP 405 error: HTTP Method not allowed. It seems to be a problem with the method in the form, POST, but I have no clue what.
  I have checked the apache error log in XAMPP but without success. Nothing had been logged at the time of problem occurence</p>
  <p>HTML (only the form part with no CSS):</p>
  <pre><code>&lt;body&gt;
      &lt;div class=&quot;login&quot;&gt;
          &lt;h1&gt;Login&lt;/h1&gt;
          &lt;form action=&quot;authenticate.php&quot; method=&quot;post&quot;&gt;
              &lt;label for=&quot;username&quot;&gt;
                  &lt;i class=&quot;fas fa-user&quot;&gt;&lt;/i&gt;
              &lt;/label&gt;
              &lt;input type=&quot;text&quot; name=&quot;username&quot; placeholder=&quot;Username&quot; id=&quot;username&quot; required&gt;
              &lt;label for=&quot;password&quot;&gt;
                  &lt;i class=&quot;fas fa-lock&quot;&gt;&lt;/i&gt;
              &lt;/label&gt;
              &lt;input type=&quot;password&quot; name=&quot;password&quot; placeholder=&quot;Password&quot; id=&quot;password&quot; required&gt;
              &lt;input type=&quot;submit&quot; value=&quot;Login&quot;&gt;
          &lt;/form&gt;
      &lt;/div&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>PHP (The authenticate.php file):</p>
  <pre><code>&lt;?php
  session_start();
  $DATABASE_HOST = 'localhost';
  $DATABASE_USER = 'root';
  $DATABASE_PASS = '';
  $DATABASE_NAME = 'users';
  $conn = mysqli_connect($DATABASE_HOST, $DATABASE_USER, $DATABASE_PASS, $DATABASE_NAME);
  if ( mysqli_connect_errno() ) {
      exit('Failed to connect to MySQL: ' . mysqli_connect_error());
  }
  if ( !isset($_POST['username'], $_POST['password']) ) {
      exit('Please fill both the username and password fields!');
  }
  if ($stmt = $conn-&gt;prepare('SELECT id, password FROM accounts WHERE username = ?')){
  $stmt-&gt;bind_param('s', $_POST['username']);
  $stmt-&gt;execute();
  $stmt-&gt;store_result();
  }
  if ($stmt-&gt;num_rows &gt; 0) {
      $stmt-&gt;bind_result($id, $password);
      $stmt-&gt;fetch();
      if (password_verify($_POST['password'], $password)) {
          session_regenerate_id();
          $_SESSION['loggedin'] = TRUE;
          $_SESSION['name'] = $_POST['username'];
          $_SESSION['id'] = $id;
          header('Location: home.php');
      } else {
          echo 'Incorrect password!.';
      }
  } else {
      echo 'Incorrect username and/or password!';
  }
  
  $stmt-&gt;close();
  ?&gt;
  </code></pre>