Javascript 当用户登录时,将登录按钮更改为注销按钮

Javascript 当用户登录时,将登录按钮更改为注销按钮,javascript,php,jquery,html,login,Javascript,Php,Jquery,Html,Login,我已经阅读了以下链接: 我有一个问题有点具体。我有一个minimalogin文件夹,其中包含所有注册和登录PHP代码。在这个文件夹中,我有index.php,其中包含以下代码: <?php // checking for minimum PHP version if (version_compare(PHP_VERSION, '5.3.7', '<')) { exit("Sorry, Simple PHP Login does not run on a PHP ver

我已经阅读了以下链接:

我有一个问题有点具体。我有一个
minimalogin
文件夹,其中包含所有注册和登录PHP代码。在这个文件夹中,我有
index.php
,其中包含以下代码:

<?php
// checking for minimum PHP version
if (version_compare(PHP_VERSION, '5.3.7', '<')) {
    exit("Sorry, Simple PHP Login does not run on a PHP version smaller than 5.3.7 !");
} else if (version_compare(PHP_VERSION, '5.5.0', '<')) {
    // if you are using PHP 5.3 or PHP 5.4 you have to include the password_api_compatibility_library.php
    // (this library adds the PHP 5.5 password hashing functions to older versions of PHP)
    require_once("libraries/password_compatibility_library.php");
}

// include the configs / constants for the database connection
require_once("config/db.php");

// load the login class
require_once("classes/Login.php");

$login = new Login();

// ... ask if we are logged in here:
if ($login->isUserLoggedIn() == true) {

    //after logged in


} else {

    //after logged out
}
?>
但是我真的不知道如何在我的
index.php
(部分登录后)中实现这个函数

注意:我也不想输出“登录”。用户登录后,我希望输出为“Hey,[name].Logout”,而不是登录按钮,其代码为:

Hey, $_SESSION['user_name']
<a href="index.php?logout">Logout</a>"
Hey,$\u会话['user\u name']
"
2) 或者,我也这样做了:

<ul id="registerloginarea" class="nav navbar-nav navbar-right navbar-btn">
                <?php
                include("/minimallogin/index.php");

                $login = new Login();

                // ... ask if we are logged in here:
                if ($login->isUserLoggedIn() == true) {
                    // the user is logged in. you can do whatever you want here.
                    // for demonstration purposes, we simply show the "you are logged in" view.
                    echo $_SESSION['user_name'];
                    echo "<a href=\"index.php?logout\">Logout</a>";



                } else {
                    // the user is not logged in. you can do whatever you want here.
                    // for demonstration purposes, we simply show the "you are not logged in" view.
                    include("/var/www/html/C-CubeClub/includes/registerloginarea.php");
                }
                ?>
           </ul>
$login…
前面的半部分包含在
minimalogin/index.php
中。 但是当我登录时,它仍然解析
minimalogin/index.php
(因为我已经将它作为
包含在我的表单中)。 你建议我如何让这东西工作。它可能有一个非常简单的答案,但请原谅我

<ul id="registerloginarea" class="nav navbar-nav navbar-right navbar-btn">
                <?php
                include("/minimallogin/index.php");

                $login = new Login();

                // ... ask if we are logged in here:
                if ($login->isUserLoggedIn() == true) {
                    // the user is logged in. you can do whatever you want here.
                    // for demonstration purposes, we simply show the "you are logged in" view.
                    echo $_SESSION['user_name'];
                    echo "<a href=\"index.php?logout\">Logout</a>";



                } else {
                    // the user is not logged in. you can do whatever you want here.
                    // for demonstration purposes, we simply show the "you are not logged in" view.
                    include("/var/www/html/C-CubeClub/includes/registerloginarea.php");
                }
                ?>
           </ul>