title: Redirect from php file to html
body: <p>Here my <code>php</code> code. I need to redirect to another page when <code>if($users[$name] === $password)</code> or when <code>$users[$name] = $password;</code> but it does not work.What is wrong?Here ajax too.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$(document).ready(function() {
    $('#submit').click(function() {
      var name = $('#username').val();
      var password = $('#password').val();
      $.ajax({
        type: 'POST',
        url: 'php/login_script.php',
        data: {
          user: name,
          pass: password
        },
        success: function(a) {
          alert(a);
        }
      });
    });
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <pre><code>&lt;?php
  if(!isset($_POST['user'])||!isset($_POST['pass'])){
      die();
  }
  $file = "users.json";
  $users = json_decode(file_get_contents($file), true);
  $name = $_POST['user'];
  $password = $_POST['pass'];
  
  if(isset($users[$name])) {
      if($users[$name] === $password){
          header("Location:chat.html");
          exit;
      }
      else {
          echo "Wrong password";
      }
  } 
  else {
      $users[$name] = $password;
      file_put_contents($file, json_encode($users, JSON_PRETTY_PRINT));
      header("Location:chat.html");
      exit;
  }
  </code></pre>