I'm not sure what your function islogged() contains but your first page should look more like the following as there are 3 errors:
<?php include('includes/config.php');
$user = mysql_real_escape_string($_POST['username']);
$password = md5(addslashes($_POST['password']));
$userrow = mysql_query("SELECT * FROM users WHERE user_username = '" . $user . "' AND user_password = '" . $password . "'") or die('Error 1: '.mysql_error());
if (mysql_num_rows($userrow) == 1) {
ob_start();
if (isset ($_POST['rememberme'])) {
setcookie('username', $_POST['username'], time() + 60 * 60 * 24 * 365, '/', 'www.mysite.com');
setcookie('password', md5($_POST['password']), time() + 60 * 60 * 24 * 365, '/', 'www.mysite.com');
}
else {
setcookie('username', $_POST['username'], false, '/', 'www.mysite.com');
setcookie('password', md5($_POST['password']), false, '/', 'www.mysite.com');
}
header('Location: index.php');
ob_end_flush();
}
else {
echo 'Username/Password Invalid';
}
?>