Beispiel #1
0
function userLogin()
{
    global $userAccount, $userPassword;
    // if form is submitted then try to login
    // $_POST['doLogin'] is related to the name of the login-button
    $output = null;
    $outputClass = null;
    if (isset($_POST['doLogin'])) {
        // does account and password match?
        if ($userAccount == $_POST['account'] && $userPassword == userPassword($_POST['password'])) {
            $output = "Du är nu inloggad. Menyn uppe i högra hörnet har ändrat sig.";
            $outputClass = "success";
            $_SESSION['authenticated'] = true;
        } else {
            $output = "Du lyckades ej logga in. Felaktigt konto eller lösenord.";
            $outputClass = "error";
        }
    }
    return userLoginForm($output, $outputClass);
}
Beispiel #2
0
<?php

error_reporting(-1);
// start a named session
session_name(preg_replace('/[:\\.\\/-_]/', '', __FILE__));
session_start();
// time page generation, display in footer. comment out to disable timing.
$pageTimeGeneration = microtime(true);
// include common functions
include_once dirname(__FILE__) . "/../src/common.php";
// include functions for login & logout
include_once dirname(__FILE__) . "/../src/login.php";
// account and password that can login
$userAccount = "bex";
$userPassword = userPassword("bex");