示例#1
0
<header class="header">
    <?php 
// ================================================================================================================
// LOGIN
if (isset($_POST['username']) && isset($_POST['password'])) {
    // try to log in.
    if ($authHandler->loginUser($_POST['username'], $_POST['password'])) {
        echo "<div class='notification success'>Hi " . $authHandler->getUserName() . ", you are now logged in!</div>";
    } else {
        echo "<div class='notification error'>We're sorry, but the log in failed. Is the password correct?</div>";
    }
}
// LOGOUT
if (isset($_POST['logout'])) {
    $authHandler->logoutUser();
}
// ================================================================================================================
?>
    <div class="brand">Notes</div>

    <?php 
if ($authHandler->isUserLoggedIn()) {
    ?>

    <div class="profile">
        <form method="post" class="logout">
            <input type="submit" value="Log out" name="logout"/>
        </form>
        <div class="username"><?php 
    echo $authHandler->getUserName();