'.mysql_error());
}
mysql_select_db($mysql_database, $db) or die('Failed to select database
'.mysql_error());
$sql = "SELECT * FROM ".$mysql_table." WHERE username = '".mysql_real_escape_string($_POST['username'])."'";
$result = mysql_query($sql, $db);
if ($data = mysql_fetch_array($result))
{
if ($crypt_pass == $data['password'] && $data['active'] != 0)
{
$found = true;
$db_fullname = $data['fullname'];
$db_username = $data['username'];
}
}
mysql_close($db);
if ($found == false)
{
header('Location: '.$error_page);
exit;
}
else
{
$_SESSION['username'] = $db_username;
$_SESSION['fullname'] = $db_fullname;
$_SESSION['expires_by'] = time() + $session_timeout;
$_SESSION['expires_timeout'] = $session_timeout;
$rememberme = isset($_POST['rememberme']) ? true : false;
if ($rememberme)
{
setcookie('username', $db_username, time() + 3600*24*30);
setcookie('password', $_POST['password'], time() + 3600*24*30);
}
header('Location: '.$success_page);
exit;
}
}
$username = isset($_COOKIE['username']) ? $_COOKIE['username'] : '';
$password = isset($_COOKIE['password']) ? $_COOKIE['password'] : '';
?>