<?php

require_once '../login_001/includes/init.php';
use Foundationphp\Sessions\AutoLogin;
if (isset($_POST['login'])) {
    $mmbrname = trim($_POST['mmbrname']);
    $pwd = trim($_POST['pwd']);
    $stmt1 = $db->prepare('SELECT pwd, mmbr_key FROM mmbrs LEFT JOIN mmbr_dtl USING (mmbr_key) WHERE mmbrname = :mmbrname');
    $stmt1->bindParam(':mmbrname', $mmbrname);
    $stmt1->execute();
    $stored = $stmt1->fetchColumn();
    if (password_verify($pwd, $stored)) {
        session_regenerate_id(true);
        $_SESSION['mmbrname'] = $mmbrname;
        $_SESSION['authenticated'] = true;
        if (isset($_POST['remember'])) {
            // create persistent login
            $autologin = new AutoLogin($db);
            $autologin->persistentLogin();
        }
        /** INDEV: linking to mmbrs default genre page GOAL: link mmbrname from mmbrs to mmbr_key in mmbr_dtl */
        $query_genre = $stmt1->fetchColumn();
        $mmbr_genre_row = $query_genre['mmbr_genre'];
        //$mmbr_genre_row in header redirect remains empty.
        header("Location: ../login_001/{$mmbr_genre_row}.php");
        exit;
        //{
    } else {
        $error = '<p class="text-center error">Login failed. Check username and password.</p>';
    }
}
Example #2
0
<?php

require_once __DIR__ . '/init.php';
use Foundationphp\Sessions\AutoLogin;
if (isset($_SESSION['authenticated']) || isset($_SESSION['lynda_auth'])) {
    // we're OK
} else {
    $autologin = new AutoLogin($db);
    $autologin->checkCredentials();
    if (!isset($_SESSION['lynda_auth'])) {
        header('Location: login.php');
        exit;
    }
}
Example #3
0
    <title>Logout</title>
    <meta charset="utf-8">
</head>
<body>
<h1>Log Out</h1>
<form action="<?php 
    echo $_SERVER['PHP_SELF'];
    ?>
" method="post">
    <p>
        <input type="submit" name="single" value="Don't remember me in this browser/computer">
        <input type="submit" name="all" value="Don't remember me on any computer">
    </p>
    <p>
        <input type="submit" name="cancel" value="Cancel">
    </p>
</form>
</body>
</html>
<?php 
} elseif (isset($_POST['single']) || isset($_POST['all'])) {
    $autologin = new AutoLogin($db);
    if (isset($_POST['single'])) {
        $autologin->logout(false);
    } else {
        $autologin->logout(true);
    }
    logout_sess();
} elseif (isset($_POST['logout'])) {
    logout_sess();
}
Example #4
0
    $stmt = $db->prepare('SELECT pwd FROM users WHERE username = :username');
    $stmt->bindParam(':username', $username);
    $stmt->execute();
    $stored = $stmt->fetchColumn();
    if (password_verify($pwd, $stored)) {
        session_regenerate_id(true);
        $_SESSION['revalidated'] = true;
        unset($_SESSION['invalid']);
        header('Location: ' . $_SESSION['return_to']);
        exit;
    } else {
        $error = 'Incorrect username or password';
        $_SESSION['invalid']++;
        if ($_SESSION['invalid'] == $max_attempts) {
            if (isset($_SESSION['remember']) || isset($_SESSION['lynda_auth'])) {
                $autologin = new AutoLogin($db);
                $autologin->logout();
            }
            logout_sess();
        }
    }
}
?>
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>Revalidation</title>
    <link href="css/styles.css" rel="stylesheet" type="text/css">
</head>
<body>