Something is entirely wrong with this code,when I try to load it the page is showing 'Please wait....' and nothing happens

header.php

<div class="page-loader-wrapper">
    <div class="loader">
        <div class="m-t-30"><img src="icon_black.svg" width="48" height="48" alt="ArrOw"></div>
        <p>Please wait...</p>
    </div>
</div>
<nav class="navbar custom-navbar navbar-expand-lg py-2">
    <div class="container-fluid px-0">
        <a href="javascript:void(0);" class="menu_toggle"><i class="fa fa-align-left"></i></a>
        <a href="dashboard.php" class="navbar-brand"><strong>Garbage Management</strong> System</a>
        <div id="navbar_main">
            <ul class="navbar-nav mr-auto hidden-xs">
                <li class="nav-item page-header">
                    <ul class="breadcrumb">
                        <li class="breadcrumb-item"><a href="dashboard.php"><i class="fa fa-home"></i></a></li>
                        <li class="breadcrumb-item active">Dashboard</li>
                    </ul>
                </li>
            </ul>
            <ul class="navbar-nav ml-auto">
                <li class="nav-item dropdown">
                    <a class="nav-link nav-link-icon" href="javascript:void(0);" id="navbar_1_dropdown_3" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i class="fa fa-user"></i></a>
                    <div class="dropdown-menu dropdown-menu-right">
                        <h6 class="dropdown-header">User menu</h6>
                        <a class="dropdown-item" href="profile.php"><i class="fa fa-user text-primary"></i>My Profile</a>
                        <a class="dropdown-item" href="change-password.php"><i class="fa fa-cog text-primary"></i>Settings</a>
                        <div class="dropdown-divider" role="presentation"></div>
                        <a class="dropdown-item" href="logout.php"><i class="fa fa-sign-out text-primary"></i>Sign out</a>
                    </div>
                </li>
            </ul>
        </div>
    </div>
</nav>

sidebar.php

<div class="left_sidebar">
    <nav class="sidebar">
        <div class="user-info">
            <div class="image"><a href="javascript:void(0);"><img src="" alt="User"></a></div>
            <div class="detail mt-3">
                <?php
                $uid=$_SESSION['uuid'];
                $sql="select Full_Name,Gmail from user where user_id=:uid";
                $query=$con->prepare($sql);
                $query->bindParam(':uid',$uid,PDO::PARAM_STR);
                $query->execute();
                $results=$query->fetchAll(PDO::FETCH_OBJ);
                foreach $results as $row{
                    $mail=$row->Gmail;
                    $name=$row->Full_Name;
                }
                ?>
                <h5 class="mb-0"><?php echo $name;?></h5>
                <small><?php echo $mail;?></small>
            </div>
        </div>
        <ul id="main-menu" class="metismenu">
            <li class="active"><a href="dashboard.php"><i class="ti-home"></i><span>Dashboard</span></a></li>
            <li><a href="lodge-complaint.php"><i class="ti-files"></i><span>lodge Complain</span></a></li>
            <li><a href="lodge-request.php"><i class="ti-files"></i><span>lodge Request</span></a></li>
            <li><a href="complaint-history.php"><i class="ti-files"></i><span>Complain History</span></a></li>
            <li><a href="request-history.php"><i class="ti-files"></i><span>Request History</span></a></li>
            <li><a href="search.php"><i class="ti-search"></i><span>Search</span></a></li>
        </ul>
    </nav>
</div>

dashboard.php

<?php
session_start();
error_reporting(0);
include('configure.php');
if (strlen($_SESSION['uuid']==0)) 
{
  header('location:signout.php');
} 
else
{
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <title>User dashboard</title>
    <link rel="stylesheet" href="new.css" type="text/css">
    <link rel="stylesheet" href="../themify-icons/themify-icons.css">
    <link rel="stylesheet" href="../fontawesome/css/fontawesome.min.css">
    <link rel="stylesheet" href="../jquery-jvectormap-2.0.5">
    <link rel="stylesheet" href="../charts-c3/plugin.css">
</head>
<body class="theme-indigo">
    <?php include_once('include/header.php');?>
    <div class="main_content" id="main-content">
        <?php include_once('include/sidebar.php'); ?>
        <div class="page">
            <nav class="navbar navbar-expand-lg navbar-light bg-light">
                <a class="navbar-brand" href="dashboard.php">Dashboard</a>
            </nav>
            <div class="container-fluid">
                <div class="row clearfix">
                    <div class="col-lg-12 col-md-6 col-sm-12">
                        <div class="card widget_2 big-icon traffic">
                            <div class="body">
                                <?php
                                 $uid=$_SESSION['uuid'];
                                 $sql="SELECT Full_Name,Gmail from user where user_id=:uid"; 
                                 $query=$con->prepare($sql);
                                 $query->bindParam(':uid',$uid,PDO::PARAM_STR);
                                 $query->execute();
                                 $results=$query->fetchAll(PDO::FETCH_OBJ);
                                 foreach ($results as $row)
                                 {
                                    $mail=$row->Gmail;   
                                    $name=$row->Full_Name; 
                                 }
                                ?>
                                <h4 style="color:red;"> Welcome <?php echo $name; ?></h4>
                                <a href="profile.php" class="btn btn-primary"><small>View Profile</small></a>
                                <?php
                                 $sql="select user.user_id as uid from complain,user join user on user.user_id=complain.user_id where complain.user_id=:uid and (complain.Status is null || complain.Status='')";
                                 $query=$con-> prepare($sql);
                                 $query->bindParam(':uid',$uid,PDO::PARAM_STR);
                                 $query->execute();
                                 $results=$query->fetchAll(PDO::FETCH_OBJ);
                                 $totalcomplain=$query->rowCount(); 
                                ?>
                                <div class="row clearfix" style="margin-top:2%;">
                                    <div class="col-lg-4 col-md-6 col-sm-12">
                                        <div class="card widget_2 big_icon traffic">
                                            <div class="body" style="border:solid #000 1px">
                                                <h6>Total Lodged Complain</h6>
                                                <h2><?php echo $totalcomplain;?></h2>
                                                <a href="lodged-complain-history.php"><small> View Detail</small></a>
                                            </div>
                                        </div>
                                    </div>
                                    <?php 
                                      $sql="select user.user_id as uid from requests,user join user on user.user_id=requests.user_id where requests.user_id=:uid and (requests.Status is null || requests.Status='')";
                                      $query=$con-> prepare($sql);
                                      $query->bindParam(':uid',$uid,PDO::PARAM_STR);
                                      $query->execute();
                                      $results=$query->fetchAll(PDO::FETCH_OBJ);
                                      $totalrequest=$query->rowCount(); 
                                    ?>
                                    <div class="col-lg-4 col-md-6 col-sm-12">
                                        <div class="card widget_2 big_icon traffic">
                                            <div class="body" style="border:solid #000 1px">
                                                <h6>Total Lodged Request</h6>
                                                <h2><?php echo $totalrequest;?></h2>
                                                <a href="lodged-request-history.php"><small> View Detail</small></a>
                                            </div>
                                        </div>
                                    </div>
                                    <?php 
                                     $sql="select user.user_id as uid from complain,user join user on user.user_id=complain.user_id where complain.user_id=:uid and (complain.Status='Completed')";
                                     $query=$con-> prepare($sql);
                                     $query->bindParam(':uid',$uid,PDO::PARAM_STR);
                                     $query->execute();
                                     $results=$query->fetchAll(PDO::FETCH_OBJ);
                                     $completedcomplain=$query->rowCount(); 
                                    ?>
                                    <div class="col-lg-4 col-md-6 col-sm-12">
                                        <div class="card widget_2 big_icon email">
                                            <div class="body" style="border:solid #009900 1px">
                                                <h6>Completed Lodged Complain</h6>
                                                <h2><?php echo $completedcomplain;?></h2>
                                                <a href="lodged-complain-history.php"><small> View Detail</small></a>
                                            </div>
                                        </div>
                                    </div>
                                    <?php 
                                     $sql="select user.user_id as uid from requests,user join user on user.user_id=requests.user_id where requests.user_id=:uid and (requests.Status='Completed')";
                                     $query=$con-> prepare($sql);
                                     $query->bindParam(':uid',$uid,PDO::PARAM_STR);
                                     $query->execute();
                                     $results=$query->fetchAll(PDO::FETCH_OBJ);
                                     $completedrequests=$query->rowCount(); 
                                    ?>
                                    <div class="col-lg-4 col-md-6 col-sm-12">
                                        <div class="card widget_2 big_icon email">
                                            <div class="body" style="border:solid #009900 1px">
                                                <h6>Completed Lodged Requests</h6>
                                                <h2><?php echo $completedrequests;?></h2>
                                                <a href="lodged-request-history.php"><small> View Detail</small></a>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
<script src="../assets/bundles/c3.bundle.js"></script>
<script src="../assets/bundles/jvectormap.bundle.js"></script>  
<script src="../assets/bundles/libscripts.bundle.js"></script>  
<script src="../assets/byndles/vendorscripts.bundle.js"></script>  
<script src="../assets/js/theme.js"></script>  
<script src="../assets/js/pages/todo-js.js"></script>  
<script src="../assets/js/pages/index.js"></script>     
</body>
</html>
<?php } ?>

I would suggest you start first with getting all the DB code out from the middle of your HTML. At the least create functions and then test each one and make sure they return what you expect them to. Then call the functions where they are needed. You have way too much duplicate code.

2 Likes

What debugging have you done so far? How far through the code does it get before it stops doing anything? I can’t see any code to handle what happens if the user_id doesn’t exist. If you view the source of the html page in your browser, is there anything else there?

1 Like

You’ve turned off error reporting. That’s not a good start.

1 Like

Where’s the bit of code that’s supposed to remove the loader?

Look for missing parentheses () in the foreach statement on sidebar.php.

foreach($results as $row){

So, as others have alluded to, learn to do some debugging. When I loaded the page and viewed the page source looking for errors I didn’t see any, but what I also didn’t see was much of the page. I commented out all queries on the dashboard page and full page still didn’t load. Once I commented the includes for header and sidebar the page loaded. I questioned the query on the sidebar page and even printed out $results and saw the expected query results. It was then, OH! there’s the problem when I looked the foreach. So the point is to figure out the point it stops working and fix the issue.

2 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.