Example #1
0
if (isset($_GET['action'])) {
    //die "p";
    $action = $_GET['action'];
} else {
    //die "a";
    $action = "";
}
$mUser = User::getCurrentUser();
switch ($action) {
    case "login":
        $username = $_POST['username'];
        $password = $_POST['password'];
        $rememberme = $_POST['rememberme'];
        if ($mUser->login($username, $password)) {
            $mUser = new User($username, $password, $mUser->getCompany());
            if ($mUser->getActivatedState() == 1) {
                if ($rememberme) {
                    $mUser->SetCookieforUser($username, $password, $mUser->getCompany());
                }
                echo "Redirecting to dashboard.";
                echo "<script>window.location.href = 'index.php'</script>";
                //header('Location:index.php');
            } else {
                echo "<script>window.location.href = 'activate.php'</script>";
            }
        } else {
            echo "<script>alert('Username or Password incorrect. Please try again.');</script>";
            echo "<script>window.location.href = 'login.php'</script>";
            //header('Location:login.php');
        }
        break;