title: Redirects - alternative to "<meta http-equiv='refresh' />"?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1255022/best-redirect-methods">Best redirect methods?</a>  </p>
  </blockquote>
  
  
  
  <p>Hello</p>
  
  <p>I am working with some legacy code that includes a module for user registration / login.  There is a block that queries the DB to see if the user is logged in, then re-directs to the login page. </p>
  
  <p>The re-direct is handled by <code>&lt;meta http-equiv='refresh' content='=2;index.php' /&gt;</code> but I have since learnt this is depreciated, and doesn't work in all browsers.</p>
  
  <p>Is there an alternative way to put a re-direct within the code below?</p>
  
  <pre><code>    $username = mysql_real_escape_string($_POST['username']);
      $password = md5(mysql_real_escape_string($_POST['password']));
  
      $checklogin = mysql_query("SELECT * FROM users WHERE username = '".$username."' AND password = '".$password."'");
  
      if(mysql_num_rows($checklogin) == 1)
      {
          $row = mysql_fetch_array($checklogin);
          $email = $row['email'];
  
          $_SESSION['username'] = $username;
          $_SESSION['email'] = $email;
          $_SESSION['LoggedIn'] = 1;
  
          echo "&lt;h1&gt;Success&lt;/h1&gt;";
          echo "&lt;p&gt;We are now redirecting you&lt;/p&gt;";
          echo "&lt;meta http-equiv='refresh' content='=2;index.php' /&gt;";
      }
      else
      {
          echo "&lt;h2&gt;Error&lt;/h2&gt;";
          echo "&lt;p&gt;Sorry, your account could not be found. Please &lt;a href=\"index.php\"&gt;click here to try again&lt;/a&gt;.&lt;/p&gt;";
      }
  </code></pre>
  
  <p>Many thanks for any pointers.</p>