1

I am making a really big system for my YouTube network and I am kind of confused with why my bootstrap dropdown doesn't work. It worked all fine until I put the PHP code in it to check if the user is logged in.

Here's my code:

 <?php
require_once 'core/init.php';
?>
<html lang="en">

<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Bgtracker Group | Home</title>

    <!-- Bootstrap Core CSS -->
    <link href="css/bootstrap.min.css" rel="stylesheet">

    <!-- Custom CSS -->
    <style>
    body {
        padding-top: 70px;
        /* Required padding for .navbar-fixed-top. Remove if using .navbar-static-top. Change if height of navigation changes. */
    }
    </style>

</head>

<body>

    <!-- Navigation -->

    <div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
        <div class="container">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="#">Bgtracker Group</a>
            </div>
            <div class="navbar-collapse collapse">
                <ul class="nav navbar-nav navbar-right">
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown">Menu<b class="caret"></b></a>
                        <ul class="dropdown-menu">
                            <li class="dropdown-header">General Links</li>
                            <li><a href="about.php">About Us</a></li>
                            <li><a href="partner.php">Become a partner</a></li>
                            <li><a href="recruiter.php">Become a recruiter</a></li>
                            <li><a href="network.php">Become a network</a></li>
                            <li><a href="about.php">About Us</a></li>
                            <li><a href="contact.php">Contact Us</a></li>
                            <li class="dropdown-header">System Links</li>
                            <?php
                            $user = new user();
                            if(!$user->isLoggedIn()) {
                                echo "<li><a href='login.php'>Log-in</a></li>";
                            } else if($user->isLoggedIn()) {
                                echo "<li><a href='update.php'>Update Profile</a></li>";
                                echo "<li><a href='changepassword.php'>Change Password</a></li>";
                                echo "<li><a href='logout.php'>Log-out</a></li>";
                            }
                            if($user->isLoggedIn()) {
                                if($user->hasPermission('admin')) {
                                echo "<li><a href='#'>|</a></li>";
                                echo "<li><a href='admin.php'>Admin CP</a></li>";
                                }
                                return false;
                            }
                            ?>
                        </ul>
                    </li>
                </ul>
            </div>
        </div>
    </div>
    <!-- Page Content -->
    <div class="container">

        <div class="row">
            <div class="col-lg-12 text-center">
                <h1>
                    <?php
                    if($user->isLoggedIn()) {
                        echo "Welcome, ";
                        echo escape($user->data()->username);
                        echo "!";
                    } else if(!$user->isLoggedIn()) {
                        echo "Welcome, guest!";
                    }


                    //YouTube Stats


                    ?>
                </h1>
            </div>
        </div>
        <!-- /.row -->

    </div>
    <!-- /.container -->

    <!-- jQuery Version 1.11.1 -->
    <script src="js/jquery.js"></script>

    <!-- Bootstrap Core JavaScript -->
    <script src="js/bootstrap.min.js"></script>

</body>

</html>
5
  • is that file .php or able to be treated as PHP? Commented Aug 8, 2015 at 15:20
  • Yes. The file is a .php. Commented Aug 8, 2015 at 15:22
  • Add error reporting to the top of your file(s) right after your opening PHP tag for example <?php error_reporting(E_ALL); ini_set('display_errors', 1); then the rest of your code, to see if it yields anything. Commented Aug 8, 2015 at 15:23
  • No errors are shown in my php code. It seems to be all fine. Commented Aug 8, 2015 at 15:24
  • Did you try interchangeing " and ' quotes? So that you have for instance: echo '<li><a href="admin.php">Admin CP</a></li>'; Commented Aug 8, 2015 at 15:37

1 Answer 1

1

I managed to fix it myself. It was the 'return false' statement. It was somehow returning false on my code and thus not displaying anything. I put it there with the mindset that if the user is not logged in it will just not display anything but oh well.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.