I have login page in which I have a login form with action='checklogin.php'. It looks for username & password and if everything is alright, it sets email cookie & redirected to home page. I'm using ob_flush() at the start of checklogin.php because otherwise it gives you an error 'Headers already sent'. Now the problem is it works fine with Chrome, Firefox, Opera but not working in IE & Safari. Have a look at my code.
<?php
ob_start();
session_start();
include 'dbconnect.php';
$email = $_POST['email'];
$password = $_POST['password'];
$epassword = md5($password);
$q = "select * from users where email='$email' and password='$epassword'";
$r = mysql_query($q);
if ($obj = mysql_fetch_object($r)) {
$time = time();
if (isset($_POST['rememberme'])) {
/* Set cookie to last 30 days */
setcookie('email', $_POST['email'], time() + 3600 * 24 * 30, 'www.example.com');
} else {
setcookie('email', $_POST['email'], false, 'www.example.com');
}
echo "<script type='text/javascript'>";
echo "window.location='index.php'";
echo "</script>";
} else {
echo "<script type='text/javascript'>";
echo "window.location='login.php?message=Oops! Wrong Combination'";
echo "</script>";
}
?>
Any idea what other things I should include or I should change to have it worked in IE? Excuse my formatting, it never displays correctly with Ctrl+K.