Possible Duplicate:
Best redirect methods?
Hello
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.
The re-direct is handled by <meta http-equiv='refresh' content='=2;index.php' />
but I have since learnt this is depreciated, and doesn't work in all browsers.
Is there an alternative way to put a re-direct within the code below?
$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 "<h1>Success</h1>";
echo "<p>We are now redirecting you</p>";
echo "<meta http-equiv='refresh' content='=2;index.php' />";
}
else
{
echo "<h2>Error</h2>";
echo "<p>Sorry, your account could not be found. Please <a href=\"index.php\">click here to try again</a>.</p>";
}
Many thanks for any pointers.